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 /*******************************************************************
55 * @brief Fills mac cell group config to be sent to scheduler
59 * Function : fillMacCellGroupCfg
61 * Functionality: Fills mac cell group config to be sent to sch
63 * @params[in] macCellGrp : mac cell group config at MAC
64 * *macCellGrpCfg : mac cell group cfg to be filled
65 * @return ROK - success
68 * ****************************************************************/
69 uint8_t fillMacCellGroupCfg(MacCellGrpCfg macCellGrp, SchMacCellGrpCfg *macCellGrpCfg)
72 SchSchedReqCfg *schedReqCfg;
75 /* Copy scheduling request config */
76 schedReqCfg = &macCellGrpCfg->schedReqCfg;
77 schedReqCfg->addModListCount = macCellGrp.schReqCfg.addModListCount;
78 if(schedReqCfg->addModListCount > MAX_NUM_SR_CFG_PER_CELL_GRP)
80 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
81 schedReqCfg->addModListCount, MAX_NUM_SR_CFG_PER_CELL_GRP);
84 for(idx = 0; idx < schedReqCfg->addModListCount; idx++)
86 schedReqCfg->addModList[idx].schedReqId = \
87 macCellGrp.schReqCfg.addModList[idx].schedReqId;
88 schedReqCfg->addModList[idx].srProhibitTmr = \
89 macCellGrp.schReqCfg.addModList[idx].srProhibitTmr;
90 schedReqCfg->addModList[idx].srTransMax = \
91 macCellGrp.schReqCfg.addModList[idx].srTransMax;
93 schedReqCfg->relListCount = macCellGrp.schReqCfg.relListCount;
96 tagCfg = &macCellGrpCfg->tagCfg;
97 tagCfg->addModListCount = macCellGrp.tagCfg.addModListCount;
98 if(tagCfg->addModListCount > MAX_NUM_TAGS)
100 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
101 tagCfg->addModListCount, MAX_NUM_TAGS);
104 for(idx = 0; idx < tagCfg->addModListCount; idx++)
106 tagCfg->addModList[idx].tagId = \
107 macCellGrp.tagCfg.addModList[idx].tagId;
108 tagCfg->addModList[idx].timeAlignmentTmr = \
109 macCellGrp.tagCfg.addModList[idx].timeAlignTimer;
111 tagCfg->relListCount = macCellGrp.tagCfg.relListCount;
113 /* Copy PHR config */
114 if(macCellGrp.phrCfgSetupPres)
116 macCellGrpCfg->phrCfg.periodicTmr = macCellGrp.phrCfg.periodicTimer;
117 macCellGrpCfg->phrCfg.prohibitTmr = macCellGrp.phrCfg.prohibitTimer;
118 macCellGrpCfg->phrCfg.txpowerFactorChange = macCellGrp.phrCfg.txPowerFactor;
119 macCellGrpCfg->phrCfg.multiplePhr = macCellGrp.phrCfg.multiplePHR;
120 macCellGrpCfg->phrCfg.dummy = macCellGrp.phrCfg.dummy;
121 macCellGrpCfg->phrCfg.type2OtherCell = macCellGrp.phrCfg.phrType2OtherCell;
122 macCellGrpCfg->phrCfg.modeOtherCG = macCellGrp.phrCfg.phrOtherCG;
128 /*******************************************************************
130 * @brief Fills phy cell group config to be sent to scheduler
134 * Function : fillPhyCellGroupCfg
136 * Functionality: Fills phy cell group config to be sent to sch
138 * @params[in] macUeCfg : Phy cell group config at MAC
139 * *schPhyCellGrp : phy cell group config to be filled
140 * @return ROK - success
143 * ****************************************************************/
144 uint8_t fillPhyCellGroupCfg(PhyCellGrpCfg macUeCfg, SchPhyCellGrpCfg *schPhyCellGrp)
146 schPhyCellGrp->pdschHarqAckCodebook = macUeCfg.pdschHarqAckCodebook;
147 schPhyCellGrp->pNrFr1 = macUeCfg.pNrFr1;
152 /*******************************************************************
154 * @brief Fills PDSCh serving cell config to send to scheduler
158 * Function : fillPdschServCellCfg
160 * Functionality: Fills PDSCh serving cell config to send to scheduler
162 * @params[in] macPdschCfg : Pdsch serving cell config at MAC
163 * *schPdschCfg : Pdsch serving cell config to be filled
164 * @return ROK - success
167 * ****************************************************************/
168 uint8_t fillPdschServCellCfg(PdschServCellCfg macPdschCfg, SchPdschServCellCfg *schPdschCfg)
170 if(macPdschCfg.maxMimoLayers)
172 if(!schPdschCfg->maxMimoLayers)
174 MAC_ALLOC_SHRABL_BUF(schPdschCfg->maxMimoLayers, sizeof(uint8_t));
175 if(!schPdschCfg->maxMimoLayers)
177 DU_LOG("\nERROR --> MAC :Memory Alloc MimoLayers Failed at fillPdschServCellCfg()");
181 *schPdschCfg->maxMimoLayers = *macPdschCfg.maxMimoLayers;
185 schPdschCfg->maxMimoLayers = NULLP;
188 schPdschCfg->numHarqProcForPdsch = \
189 macPdschCfg.numHarqProcForPdsch;
191 if(macPdschCfg.maxCodeBlkGrpPerTb)
193 if(!schPdschCfg->maxCodeBlkGrpPerTb)
195 MAC_ALLOC_SHRABL_BUF(schPdschCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
196 if(!schPdschCfg->maxCodeBlkGrpPerTb)
198 DU_LOG("\nERROR --> MAC :Memory Alloc for code Block Failed at fillPdschServCellCfg()");
202 *schPdschCfg->maxCodeBlkGrpPerTb = *macPdschCfg.maxCodeBlkGrpPerTb;
206 schPdschCfg->maxCodeBlkGrpPerTb = NULLP;
209 if(macPdschCfg.codeBlkGrpFlushInd)
211 if(!schPdschCfg->codeBlkGrpFlushInd)
213 MAC_ALLOC_SHRABL_BUF(schPdschCfg->codeBlkGrpFlushInd, sizeof(bool));
214 if(!schPdschCfg->codeBlkGrpFlushInd)
216 DU_LOG("\nERROR --> MAC :Memory Alloc for Flush Ind Failed at fillPdschServCellCfg()");
220 *schPdschCfg->codeBlkGrpFlushInd = *macPdschCfg.codeBlkGrpFlushInd;
224 schPdschCfg->codeBlkGrpFlushInd = NULLP;
227 if(macPdschCfg.xOverhead)
229 if(!schPdschCfg->xOverhead)
231 MAC_ALLOC_SHRABL_BUF(schPdschCfg->xOverhead, sizeof(SchPdschXOverhead));
232 if(!schPdschCfg->xOverhead)
234 DU_LOG("\nERROR --> MAC :Memory Alloc for xOverHead Failed at fillPdschServCellCfg()");
238 *schPdschCfg->xOverhead = *macPdschCfg.xOverhead;
242 schPdschCfg->xOverhead = NULLP;
248 /*******************************************************************
250 * @brief Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
254 * Function : fillInitalUlBwpPuschCfg
257 * Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
259 * @params[in] macPuschCfg : Initial UL-BWP PUSCH cfg at MAC
260 * schPuschCfg : Initial UL-BWP PUSCH cfg to be filled
261 * @return ROK - success
264 * ****************************************************************/
265 uint8_t fillInitalUlBwpPuschCfg(PuschCfg macPuschCfg, SchPuschCfg *schPuschCfg)
269 schPuschCfg->dataScramblingId = macPuschCfg.dataScramblingId;
270 schPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos = \
271 macPuschCfg.dmrsUlCfgForPuschMapTypeA.addPos;
272 schPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
273 macPuschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0;
274 schPuschCfg->resourceAllocType = macPuschCfg.resourceAllocType;
276 schPuschCfg->numTimeDomRsrcAlloc = macPuschCfg.numTimeDomRsrcAlloc;
277 if(schPuschCfg->numTimeDomRsrcAlloc > MAX_NUM_UL_ALLOC)
279 DU_LOG("\nERROR --> MAC : Number of Time domain resource allocation [%d] exceeds max limit [%d]",\
280 schPuschCfg->numTimeDomRsrcAlloc, MAX_NUM_UL_ALLOC);
283 for(idx = 0; idx < schPuschCfg->numTimeDomRsrcAlloc; idx++)
285 schPuschCfg->timeDomRsrcAllocList[idx].k2 = \
286 macPuschCfg.timeDomRsrcAllocList[idx].k2;
287 schPuschCfg->timeDomRsrcAllocList[idx].mappingType = \
288 macPuschCfg.timeDomRsrcAllocList[idx].mappingType;
289 schPuschCfg->timeDomRsrcAllocList[idx].startSymbol = \
290 macPuschCfg.timeDomRsrcAllocList[idx].startSymbol;
291 schPuschCfg->timeDomRsrcAllocList[idx].symbolLength = \
292 macPuschCfg.timeDomRsrcAllocList[idx].symbolLength;
295 schPuschCfg->transformPrecoder = macPuschCfg.transformPrecoder;
299 /*******************************************************************
301 * @brief Function to fillResrcSetList sent by DU
305 * Function : fillResrcSetList
307 * Functionality: Function to fillResrcSetList sent by DU
309 * @params[in] PucchResrcSetCfg pointer,
310 * SchPucchResrcSetCfg pointer
313 * ****************************************************************/
315 void fillResrcSetList(PucchResrcSetCfg *macRsrcSetList, SchPucchResrcSetCfg *schRsrcSetList)
317 uint8_t arrIdx, rsrcListIdx;
319 /* ResrcSetToAddModList */
320 schRsrcSetList->resrcSetToAddModListCount = macRsrcSetList->resrcSetToAddModListCount;
321 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
323 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
324 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId;
326 schRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
327 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize;
329 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
330 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount;
331 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].\
332 resrcListCount; rsrcListIdx++)
334 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
335 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx];
338 /* ResrcSetToRelList */
339 schRsrcSetList->resrcSetToRelListCount = macRsrcSetList->resrcSetToRelListCount;
340 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToRelListCount; arrIdx++)
342 schRsrcSetList->resrcSetToRelList[arrIdx] = macRsrcSetList->resrcSetToRelList[arrIdx];
346 /*******************************************************************
348 * @brief Function to fillResrcList sent by DU
352 * Function : fillResrcList
354 * Functionality: Function to fillResrcList sent by DU
356 * @params[in] PucchResrcCfg pointer,
357 * SchPucchResrcCfg pointer
358 * @return ROK/RFAILED;
360 * ****************************************************************/
361 uint8_t fillResrcList(PucchResrcCfg *macResrcCfg, SchPucchResrcCfg *schResrcCfg)
365 schResrcCfg->resrcToAddModListCount = macResrcCfg->resrcToAddModListCount;
366 for(arrIdx=0; arrIdx < macResrcCfg->resrcToAddModListCount; arrIdx++)
368 schResrcCfg->resrcToAddModList[arrIdx].resrcId =\
369 macResrcCfg->resrcToAddModList[arrIdx].resrcId;
370 schResrcCfg->resrcToAddModList[arrIdx].startPrb =\
371 macResrcCfg->resrcToAddModList[arrIdx].startPrb;
372 schResrcCfg->resrcToAddModList[arrIdx].intraFreqHop =\
373 macResrcCfg->resrcToAddModList[arrIdx].intraFreqHop;
374 schResrcCfg->resrcToAddModList[arrIdx].secondPrbHop =\
375 macResrcCfg->resrcToAddModList[arrIdx].secondPrbHop;
376 schResrcCfg->resrcToAddModList[arrIdx].pucchFormat =\
377 macResrcCfg->resrcToAddModList[arrIdx].pucchFormat;
378 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0)
380 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0, sizeof(SchPucchFormat0));
381 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0 == NULLP)
383 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format0 in fillResrcList()");
386 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->initialCyclicShift =\
387 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift;
388 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->numSymbols =\
389 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols;
390 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->startSymbolIdx =\
391 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx;
394 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1)
396 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1, sizeof(SchPucchFormat1));
397 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1 == NULLP)
399 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format1 in fillResrcList()");
402 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->initialCyclicShift =\
403 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift;
404 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->numSymbols =\
405 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols;
406 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->startSymbolIdx =\
407 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx;
408 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->timeDomOCC =\
409 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC;
412 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2)
414 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
415 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2 == NULLP)
417 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format2 in fillResrcList()");
420 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numPrbs =\
421 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs;
422 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numSymbols =\
423 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols;
424 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->startSymbolIdx =\
425 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx;
428 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3)
430 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
431 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3 == NULLP)
433 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format3 in fillResrcList()");
436 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numPrbs =\
437 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs;
438 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numSymbols =\
439 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols;
440 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->startSymbolIdx =\
441 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx;
444 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4)
446 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4, sizeof(SchPucchFormat4));
447 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4 == NULLP)
449 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format4 in fillResrcList()");
452 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->numSymbols =\
453 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols;
454 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->startSymbolIdx =\
455 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx;
456 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occLen =\
457 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occLen;
458 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occIdx =\
459 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx;
465 /*******************************************************************
467 * @brief Function to fillPucchFormatCfg sent by DU
471 * Function : fillPucchFormatCfg
473 * Functionality: Function to fillPucchFormatCfg
475 * @params[in] PucchFormatCfg pointer,
476 * SchPucchFormatCfg pointer
479 * ****************************************************************/
481 void fillPucchFormatCfg(PucchFormatCfg *macFormatCfg, SchPucchFormatCfg *schFormatCfg)
483 schFormatCfg->interSlotFreqHop = macFormatCfg->interSlotFreqHop;
484 schFormatCfg->addDmrs = macFormatCfg->addDmrs;
485 schFormatCfg->maxCodeRate = macFormatCfg->maxCodeRate;
486 schFormatCfg->numSlots = macFormatCfg->numSlots;
487 schFormatCfg->pi2BPSK = macFormatCfg->pi2BPSK;
488 schFormatCfg->harqAckCSI = macFormatCfg->harqAckCSI;
491 /*******************************************************************
493 * @brief Function to fillPucchSchedReqCfg sent by DU
497 * Function : fillPucchSchedReqCfg
499 * Functionality: Function to fillPucchSchedReqCfg
501 * @params[in] PucchSchedReqCfg pointer,
502 * SchPucchSchedReqCfg pointer
505 * ****************************************************************/
506 void fillPucchSchedReqCfg(PucchSchedReqCfg *macSchedReqCfg, SchPucchSchedReqCfg *schSchedReqCfg)
510 schSchedReqCfg->schedAddModListCount = macSchedReqCfg->schedAddModListCount;
511 for(arrIdx=0; arrIdx < schSchedReqCfg->schedAddModListCount; arrIdx++)
513 schSchedReqCfg->schedAddModList[arrIdx].resrcId = macSchedReqCfg->schedAddModList[arrIdx].resrcId;
514 schSchedReqCfg->schedAddModList[arrIdx].requestId = macSchedReqCfg->schedAddModList[arrIdx].requestId;
515 schSchedReqCfg->schedAddModList[arrIdx].periodicity =\
516 macSchedReqCfg->schedAddModList[arrIdx].periodicity;
517 schSchedReqCfg->schedAddModList[arrIdx].offset =\
518 macSchedReqCfg->schedAddModList[arrIdx].offset;
519 schSchedReqCfg->schedAddModList[arrIdx].resrc =\
520 macSchedReqCfg->schedAddModList[arrIdx].resrc;
522 schSchedReqCfg->schedRelListCount = macSchedReqCfg->schedRelListCount;
523 for(arrIdx=0; arrIdx < schSchedReqCfg->schedRelListCount; arrIdx++)
525 schSchedReqCfg->schedRelList[arrIdx] = macSchedReqCfg->schedRelList[arrIdx];
529 /*******************************************************************
531 * @brief Function to fillMultiCsiCfg sent by DU
535 * Function : fillMultiCsiCfg
537 * Functionality: Function to fillMultiCsiCfg
539 * @params[in] PucchMultiCsiCfg pointer,
540 * SchPucchMultiCsiCfg pointer
543 * ****************************************************************/
545 void fillMultiCsiCfg(PucchMultiCsiCfg *macCsiCfg, SchPucchMultiCsiCfg *schCsiCfg)
549 schCsiCfg->multiCsiResrcListCount = macCsiCfg->multiCsiResrcListCount;
550 for(arrIdx =0; arrIdx < schCsiCfg->multiCsiResrcListCount; arrIdx++)
552 schCsiCfg->multiCsiResrcList[arrIdx] = macCsiCfg->multiCsiResrcList[arrIdx];
556 /*******************************************************************
558 * @brief Function to fillDlToUlAck sent by DU
562 * Function : fillDlToUlAck
564 * Functionality: Function to fillDlToUlAck
566 * @params[in] PucchDlDataToUlAck pointer,
567 * SchPucchDlDataToUlAck pointer
570 * ****************************************************************/
572 void fillDlToUlAck(PucchDlDataToUlAck *macUlAck, SchPucchDlDataToUlAck *schUlAck)
576 schUlAck->dlDataToUlAckListCount = macUlAck->dlDataToUlAckListCount;
577 for(arrIdx =0; arrIdx < macUlAck->dlDataToUlAckListCount; arrIdx++)
579 schUlAck->dlDataToUlAckList[arrIdx] = macUlAck->dlDataToUlAckList[arrIdx];
583 /*******************************************************************
585 * @brief Function to fillPucchPowerControl sent by DU
589 * Function : fillPucchPowerControl
591 * Functionality: Function to fillPucchPowerControl
593 * @params[in] PucchPowerControl pointer,
594 * SchPucchPowerControl pointer
597 * ****************************************************************/
599 void fillPucchPowerControl(PucchPowerControl *macPwrCtrl, SchPucchPowerControl *schPwrCtrl)
603 schPwrCtrl->deltaF_Format0 = macPwrCtrl->deltaF_Format0;
604 schPwrCtrl->deltaF_Format1 = macPwrCtrl->deltaF_Format1;
605 schPwrCtrl->deltaF_Format2 = macPwrCtrl->deltaF_Format2;
606 schPwrCtrl->deltaF_Format3 = macPwrCtrl->deltaF_Format3;
607 schPwrCtrl->deltaF_Format4 = macPwrCtrl->deltaF_Format4;
608 schPwrCtrl->p0SetCount = macPwrCtrl->p0SetCount;
609 for(arrIdx =0; arrIdx < macPwrCtrl->p0SetCount; arrIdx++)
611 schPwrCtrl->p0Set[arrIdx].p0PucchId = macPwrCtrl->p0Set[arrIdx].p0PucchId;
612 schPwrCtrl->p0Set[arrIdx].p0PucchVal = macPwrCtrl->p0Set[arrIdx].p0PucchVal;
614 schPwrCtrl->pathLossRefRSListCount = macPwrCtrl->pathLossRefRSListCount;
615 for(arrIdx = 0; arrIdx < macPwrCtrl->pathLossRefRSListCount; arrIdx++)
617 schPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
618 macPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId;
622 /*******************************************************************
624 * @brief Function to fillOtherPucchFormatCfg sent by DU
628 * Function : fillOtherPucchFormatCfg
630 * Functionality: Function to fillOtherPucchFormatCfg
632 * @params[in] PucchFormat
633 * PucchFormatCfg pointer,
634 * SchPucchCfg pointer
637 * ****************************************************************/
639 uint8_t fillOtherPucchFormatCfg(uint8_t pucchFormat, PucchFormatCfg *macFormatCfg, SchPucchCfg *schPucchCfg)
648 MAC_ALLOC(schPucchCfg->format1, sizeof(SchPucchFormatCfg));
649 if(schPucchCfg->format1 == NULLP)
651 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 1 in fillOtherPucchFormatCfg()");
654 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format1);
662 MAC_ALLOC(schPucchCfg->format2, sizeof(SchPucchFormatCfg));
663 if(schPucchCfg->format2 == NULLP)
665 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 2 in fillOtherPucchFormatCfg()");
668 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format2);
676 MAC_ALLOC(schPucchCfg->format3, sizeof(SchPucchFormatCfg));
677 if(schPucchCfg->format3 == NULLP)
679 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 3 in fillOtherPucchFormatCfg()");
682 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format3);
690 MAC_ALLOC(schPucchCfg->format4, sizeof(SchPucchFormatCfg));
691 if(schPucchCfg->format4 == NULLP)
693 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 4 in fillOtherPucchFormatCfg()");
696 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format4);
701 DU_LOG("\nERROR --> MAC : Invalid Format Cfg %d in fillInitialUlBwpPucchCfg()", pucchFormat);
707 /*******************************************************************
709 * @brief Fills PUCCH config in initial UL BWP config for SCH UE Cfg
713 * Function : fillInitalUlBwpPucchCfg
716 * Fills PUCCH cofig in initial UL BWP config for SCH UE Cfg
718 * @params[in] macPucchCfg : Initial UL-BWP PUCCH cfg at MAC
719 * schPucchCfg : Initial UL-BWP PUCCH cfg to be filled
720 * @return ROK - success
723 * ****************************************************************/
724 uint8_t fillInitialUlBwpPucchCfg(PucchCfg *macPucchCfg, SchPucchCfg *schPucchCfg)
726 if(macPucchCfg->resrcSet)
728 MAC_ALLOC(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
729 if(schPucchCfg->resrcSet == NULLP)
731 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc set List in fillInitialUlBwpPucchCfg()");
734 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
735 fillResrcSetList(macPucchCfg->resrcSet, schPucchCfg->resrcSet);
738 if(macPucchCfg->resrc)
740 MAC_ALLOC(schPucchCfg->resrc, sizeof(SchPucchResrcCfg));
741 if(schPucchCfg->resrc == NULLP)
743 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc List in fillInitialUlBwpPucchCfg()");
746 memset(schPucchCfg->resrc, 0, sizeof(SchPucchResrcCfg));
747 if((fillResrcList(macPucchCfg->resrc, schPucchCfg->resrc)) != ROK)
749 DU_LOG("\nERROR --> MAC : Failed in fillResrcList() at fillInitialUlBwpPucchCfg()");
754 /* valid for format 1, 2, 3, 4 */
755 fillOtherPucchFormatCfg(PUCCH_FORMAT_1, macPucchCfg->format1, schPucchCfg);
756 fillOtherPucchFormatCfg(PUCCH_FORMAT_2, macPucchCfg->format2, schPucchCfg);
757 fillOtherPucchFormatCfg(PUCCH_FORMAT_3, macPucchCfg->format3, schPucchCfg);
758 fillOtherPucchFormatCfg(PUCCH_FORMAT_4, macPucchCfg->format4, schPucchCfg);
760 if(macPucchCfg->schedReq)
762 MAC_ALLOC(schPucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
763 if(schPucchCfg->schedReq == NULLP)
765 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for PucchSchedReqCfg in fillInitialUlBwpPucchCfg()");
768 memset(schPucchCfg->schedReq, 0, sizeof(SchPucchSchedReqCfg));
769 fillPucchSchedReqCfg(macPucchCfg->schedReq, schPucchCfg->schedReq);
772 if(macPucchCfg->multiCsiCfg)
774 MAC_ALLOC(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
775 if(schPucchCfg->multiCsiCfg == NULLP)
777 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for multiCsiCfg in fillInitialUlBwpPucchCfg()");
780 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
781 fillMultiCsiCfg(macPucchCfg->multiCsiCfg, schPucchCfg->multiCsiCfg);
784 //TODO: To add the support for spatial Config
785 schPucchCfg->spatialInfo = NULLP;
787 if(macPucchCfg->dlDataToUlAck)
789 MAC_ALLOC(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
790 if(schPucchCfg->dlDataToUlAck == NULLP)
792 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for dlDataToUlAck in fillInitialUlBwpPucchCfg()");
795 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
796 fillDlToUlAck(macPucchCfg->dlDataToUlAck, schPucchCfg->dlDataToUlAck);
800 if(macPucchCfg->powerControl)
802 MAC_ALLOC(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
803 if(schPucchCfg->powerControl == NULLP)
805 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for powerControl in fillInitialUlBwpPucchCfg()");
808 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
809 fillPucchPowerControl(macPucchCfg->powerControl, schPucchCfg->powerControl);
815 /*******************************************************************
817 * @brief function to free Pucch Format
821 * Function : freeSchPucchFormat
824 * function to free Pucch Format
826 * @params[in] pucchFormat, SchPucchResrcInfo Pointer,
827 * SchPucchResrcInfo pointer
829 * ****************************************************************/
831 void freeSchPucchFormat(uint8_t pucchFormat, SchPucchResrcInfo *resrcInfo, SchPucchFormatCfg *formatCfg)
835 case PUCCH_FORMAT_0 :
836 if(resrcInfo->SchPucchFormat.format0)
838 MAC_FREE(resrcInfo->SchPucchFormat.format0, sizeof(SchPucchFormat0));
839 resrcInfo->SchPucchFormat.format0 = NULLP;
843 case PUCCH_FORMAT_1 :
844 if(resrcInfo->SchPucchFormat.format1)
846 MAC_FREE(resrcInfo->SchPucchFormat.format1, sizeof(SchPucchFormat1));
847 resrcInfo->SchPucchFormat.format1 = NULLP;
851 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
852 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
856 case PUCCH_FORMAT_2 :
857 if(resrcInfo->SchPucchFormat.format2)
859 MAC_FREE(resrcInfo->SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
860 resrcInfo->SchPucchFormat.format2 = NULLP;
864 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
865 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
869 case PUCCH_FORMAT_3 :
870 if(resrcInfo->SchPucchFormat.format3)
872 MAC_FREE(resrcInfo->SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
873 resrcInfo->SchPucchFormat.format3 = NULLP;
877 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
878 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
882 case PUCCH_FORMAT_4 :
883 if(resrcInfo->SchPucchFormat.format4)
885 MAC_FREE(resrcInfo->SchPucchFormat.format4, sizeof(SchPucchFormat4));
886 resrcInfo->SchPucchFormat.format4 = NULLP;
890 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
891 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
900 /*******************************************************************
902 * @brief function to free Pucch Resrc Cfg
906 * Function : freePucchResrcCfg
909 * function to free Pucch Resrc Cfg
911 * @params[in] SchPucchResrcCfg pointer,
913 * ****************************************************************/
915 void freePucchResrcCfg(SchPucchResrcCfg *schRsrcList)
919 /* free Resrc To AddMod List */
920 for(resrcIdx = 0; resrcIdx < schRsrcList->resrcToAddModListCount; resrcIdx++)
922 freeSchPucchFormat(schRsrcList->resrcToAddModList[resrcIdx].pucchFormat,
923 &schRsrcList->resrcToAddModList[resrcIdx], NULLP);
924 memset(&schRsrcList->resrcToAddModList[resrcIdx], 0, sizeof(SchPucchResrcInfo));
926 memset(schRsrcList, 0, sizeof(SchPucchResrcCfg));
927 MAC_FREE(schRsrcList, sizeof(SchPucchResrcCfg));
930 /*******************************************************************
932 * @brief function to free Pucch Sched Req Cfg
936 * Function : freePucchSchedReqCfg
939 * function to free Pucch Sched Req Cfg
941 * @params[in] SchPucchSchedReqCfg pointer,
943 * ****************************************************************/
945 void freePucchSchedReqCfg(SchPucchSchedReqCfg *schedReqCfg)
949 for(schedReqIdx = 0; schedReqIdx < schedReqCfg->schedAddModListCount; schedReqIdx++)
951 memset(&schedReqCfg->schedAddModList[schedReqIdx], 0, sizeof(SchSchedReqResrcInfo));
953 memset(schedReqCfg, 0, sizeof(SchPucchSchedReqCfg));
954 MAC_FREE(schedReqCfg, sizeof(SchPucchSchedReqCfg));
957 /*******************************************************************
959 * @brief function to free Ul Bwp Pucch Cfg
963 * Function : freeUlBwpPucchCfg
966 * function to free Ul Bwp Pucch Cfg
968 * @params[in] SchPucchCfg pointer,
970 * ****************************************************************/
972 void freeUlBwpPucchCfg(SchPucchCfg *schPucchCfg)
974 if(schPucchCfg->resrcSet)
976 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
977 MAC_FREE(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
979 if(schPucchCfg->resrc)
981 freePucchResrcCfg(schPucchCfg->resrc);
983 if(schPucchCfg->format1)
985 freeSchPucchFormat(PUCCH_FORMAT_1, NULLP, schPucchCfg->format1);
987 if(schPucchCfg->format2)
989 freeSchPucchFormat(PUCCH_FORMAT_2, NULLP, schPucchCfg->format2);
991 if(schPucchCfg->format3)
993 freeSchPucchFormat(PUCCH_FORMAT_3, NULLP, schPucchCfg->format3);
995 if(schPucchCfg->format4)
997 freeSchPucchFormat(PUCCH_FORMAT_4, NULLP, schPucchCfg->format4);
999 if(schPucchCfg->schedReq)
1001 freePucchSchedReqCfg(schPucchCfg->schedReq);
1003 if(schPucchCfg->spatialInfo)
1005 memset(schPucchCfg->spatialInfo, 0, sizeof(SchPucchSpatialCfg));
1006 MAC_FREE(schPucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
1008 if(schPucchCfg->multiCsiCfg)
1010 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
1011 MAC_FREE(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
1013 if(schPucchCfg->dlDataToUlAck)
1015 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
1016 MAC_FREE(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
1018 if(schPucchCfg->powerControl)
1020 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
1021 MAC_FREE(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
1025 /*******************************************************************
1027 * @brief Fills initail UL BWP config to send to scheduler
1031 * Function : fillInitialUlBwp
1033 * Functionality: Fills initail UL BWP config to send to sch
1035 * @params[in] macInitUlBwp : Initial UL BWP cfg at MAC
1036 * schInitUlBwp : Initial UL BWP cfg to be filled
1037 * @return ROK - success
1040 * ****************************************************************/
1041 uint8_t fillInitialUlBwp(InitialUlBwp macInitUlBwp, SchInitialUlBwp *schInitUlBwp)
1043 schInitUlBwp->pucchCfgPres = macInitUlBwp.pucchPresent;
1044 if(schInitUlBwp->pucchCfgPres)
1046 memset(&schInitUlBwp->pucchCfg, 0, sizeof(SchPucchCfg));
1047 if(fillInitialUlBwpPucchCfg(&macInitUlBwp.pucchCfg, &schInitUlBwp->pucchCfg) != ROK)
1049 DU_LOG("\nERROR --> MAC : Failed to fill Pucch Cfg in fillInitialUlBwpPucchCfg()");
1050 freeUlBwpPucchCfg(&schInitUlBwp->pucchCfg);
1054 schInitUlBwp->puschCfgPres = macInitUlBwp.puschPresent;
1055 if(schInitUlBwp->puschCfgPres)
1057 memset(&schInitUlBwp->puschCfg, 0, sizeof(SchPuschCfg));
1058 if(fillInitalUlBwpPuschCfg(macInitUlBwp.puschCfg, &schInitUlBwp->puschCfg) != ROK)
1060 DU_LOG("\nERROR --> MAC : Failed to fill Pusch Cfg in fillInitalUlBwpPuschCfg()");
1067 /*******************************************************************
1069 * @brief Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1073 * Function : fillInitDlBwpPdcchCfg
1076 * Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1078 * @params[in] macPdcchCfg : Inital DL BWP PDCCH cfg in MAC
1079 * schPdcchCfg : Inital DL BWP PDCCH cfg to be filled
1080 * @return ROK - success
1083 * ****************************************************************/
1084 uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchCfg)
1088 /* Fill CORESET info */
1089 schPdcchCfg->numCRsetToAddMod = macPdcchCfg.numCRsetToAddMod;
1090 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1092 DU_LOG("\nERROR --> MAC : Number of CORESET to ADD/MOD [%d] exceeds max limit [%d]",\
1093 schPdcchCfg->numCRsetToAddMod, MAX_NUM_CRSET);
1097 for(idx = 0; idx < schPdcchCfg->numCRsetToAddMod; idx++)
1099 schPdcchCfg->cRSetToAddModList[idx].cRSetId = \
1100 macPdcchCfg.cRSetToAddModList[idx].cRSetId;
1101 memcpy(&schPdcchCfg->cRSetToAddModList[idx].freqDomainRsrc,\
1102 &macPdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
1103 schPdcchCfg->cRSetToAddModList[idx].duration = \
1104 macPdcchCfg.cRSetToAddModList[idx].duration;
1105 schPdcchCfg->cRSetToAddModList[idx].cceRegMappingType = \
1106 macPdcchCfg.cRSetToAddModList[idx].cceRegMappingType;
1107 schPdcchCfg->cRSetToAddModList[idx].precoderGranularity = \
1108 macPdcchCfg.cRSetToAddModList[idx].precoderGranularity;
1109 schPdcchCfg->cRSetToAddModList[idx].dmrsScramblingId = \
1110 macPdcchCfg.cRSetToAddModList[idx].dmrsScramblingId;
1113 schPdcchCfg->numCRsetToRel = macPdcchCfg.numCRsetToRel;
1114 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1116 DU_LOG("\nERROR --> MAC : Number of CORESET to release [%d] exceeds max limit [%d]",\
1117 schPdcchCfg->numCRsetToRel, MAX_NUM_CRSET);
1121 for(idx = 0; idx < schPdcchCfg->numCRsetToRel; idx++)
1126 /* Fill Search space info */
1127 schPdcchCfg->numSearchSpcToAddMod = macPdcchCfg.numSearchSpcToAddMod;
1128 if(schPdcchCfg->numSearchSpcToAddMod > MAX_NUM_SEARCH_SPC)
1130 DU_LOG("\nERROR --> MAC : Number of search space to ADD/MOD [%d] exceeds max [%d]", \
1131 schPdcchCfg->numSearchSpcToAddMod, MAX_NUM_SEARCH_SPC);
1134 for(idx = 0; idx < schPdcchCfg->numSearchSpcToAddMod; idx++)
1136 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceId = \
1137 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
1138 schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
1139 macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
1140 schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
1141 macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
1142 memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
1143 &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
1144 MONITORING_SYMB_WITHIN_SLOT_SIZE);
1145 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1 = \
1146 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1;
1147 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2 = \
1148 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2;
1149 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4 = \
1150 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4;
1151 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8 = \
1152 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8;
1153 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16 = \
1154 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16;
1155 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceType = \
1156 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceType;
1157 schPdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat = \
1158 macPdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat;
1161 schPdcchCfg->numSearchSpcToRel = macPdcchCfg.numSearchSpcToRel;
1162 if(schPdcchCfg->numSearchSpcToRel > MAX_NUM_SEARCH_SPC)
1164 DU_LOG("\nERROR --> MAC : Number of search space to release [%d] exceeds max [%d]", \
1165 schPdcchCfg->numSearchSpcToRel, MAX_NUM_SEARCH_SPC);
1168 for(idx = 0; idx < schPdcchCfg->numSearchSpcToRel; idx++)
1176 /*******************************************************************
1178 * @brief Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1182 * Function : fillInitDlBwpPdschCfg
1185 * Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1187 * @params[in] macPdschCfg : Inital DL BWP PDSCH cfg at MAC
1188 * schPdschCfg : Inital DL BWP PDSCH cfg to be filled
1189 * @return ROK - success
1192 * ****************************************************************/
1193 uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschCfg)
1197 schPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
1198 macPdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
1199 schPdschCfg->resourceAllocType = macPdschCfg.resourceAllocType;
1200 schPdschCfg->numTimeDomRsrcAlloc = macPdschCfg.numTimeDomRsrcAlloc;
1201 if(schPdschCfg->numTimeDomRsrcAlloc > MAX_NUM_DL_ALLOC)
1203 DU_LOG("\nERROR --> MAC : Number of time domain resource allocation [%d], exceeds\
1204 max limit [%d]", schPdschCfg->numTimeDomRsrcAlloc, MAX_NUM_DL_ALLOC);
1208 for(idx = 0; idx < schPdschCfg->numTimeDomRsrcAlloc; idx++)
1210 schPdschCfg->timeDomRsrcAllociList[idx].mappingType = \
1211 macPdschCfg.timeDomRsrcAllociList[idx].mappingType;
1212 schPdschCfg->timeDomRsrcAllociList[idx].startSymbol = \
1213 macPdschCfg.timeDomRsrcAllociList[idx].startSymbol;
1214 schPdschCfg->timeDomRsrcAllociList[idx].symbolLength = \
1215 macPdschCfg.timeDomRsrcAllociList[idx].symbolLength;
1218 schPdschCfg->rbgSize = macPdschCfg.rbgSize;
1219 schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
1220 schPdschCfg->bundlingType = macPdschCfg.bundlingType;
1221 if(schPdschCfg->bundlingType == STATIC_BUNDLING_TYPE)
1223 schPdschCfg->bundlingInfo.SchStaticBundling.size = macPdschCfg.bundlingInfo.StaticBundling.size;
1225 else if(schPdschCfg->bundlingType == DYNAMIC_BUNDLING_TYPE)
1227 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet1 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet1;
1228 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet2 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet2;
1233 /*******************************************************************
1235 * @brief Fill Initial DL BWP for SCH UE config
1239 * Function : fillInitialDlBwp
1241 * Functionality: Fill Initial DL BWP for SCH UE config
1243 * @params[in] macInitDlBwp : Inital DL BWP cfg at MAC
1244 * schInitDlBwp : Inital DL BWP cfg to be filled
1245 * @return ROK - success
1248 * ****************************************************************/
1249 uint8_t fillInitialDlBwp(InitialDlBwp macInitDlBwp, SchInitalDlBwp *schInitDlBwp)
1251 schInitDlBwp->pdcchCfgPres = macInitDlBwp.pdcchPresent;
1252 if(schInitDlBwp->pdcchCfgPres)
1254 if(fillInitDlBwpPdcchCfg(macInitDlBwp.pdcchCfg, &schInitDlBwp->pdcchCfg) != ROK)
1256 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdcchCfg() failed");
1261 schInitDlBwp->pdschCfgPres = macInitDlBwp.pdschPresent;
1262 if(schInitDlBwp->pdschCfgPres)
1264 if(fillInitDlBwpPdschCfg(macInitDlBwp.pdschCfg,&schInitDlBwp->pdschCfg) != ROK)
1266 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdschCfg() failed");
1273 /*******************************************************************
1275 * @brief Fills Sp Cell config to be sent to scheduler
1279 * Function : fillSpCellCfg
1281 * Functionality: Fills Sp Cell config to be sent to scheduler
1283 * @params[in] macSpCellCfg : SP cell cfg at MAC
1284 * schSpCellCfg : SP cell cfg to be filled
1285 * @return ROK - success
1288 * ****************************************************************/
1289 uint8_t fillSpCellCfg(SpCellCfg macSpCellCfg, SchSpCellCfg *schSpCellCfg)
1292 SchServCellCfgInfo *servCellCfg;
1294 schSpCellCfg->servCellIdx = macSpCellCfg.servCellIdx;
1295 servCellCfg = &schSpCellCfg->servCellCfg;
1297 /* Fill initial DL BWP */
1298 if(fillInitialDlBwp(macSpCellCfg.servCellCfg.initDlBwp, \
1299 &servCellCfg->initDlBwp) != ROK )
1301 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1305 servCellCfg->numDlBwpToAdd = macSpCellCfg.servCellCfg.numDlBwpToAdd;
1306 if(servCellCfg->numDlBwpToAdd > MAX_NUM_BWP)
1308 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1309 servCellCfg->numDlBwpToAdd, MAX_NUM_BWP);
1312 for(idx = 0; idx < servCellCfg->numDlBwpToAdd; idx++)
1314 /* TODO : As of now numDlBwpToAdd = 0 */
1317 servCellCfg->firstActvDlBwpId = macSpCellCfg.servCellCfg.firstActvDlBwpId;
1318 servCellCfg->defaultDlBwpId = macSpCellCfg.servCellCfg.defaultDlBwpId;
1319 servCellCfg->bwpInactivityTmr = NULL;
1320 if(macSpCellCfg.servCellCfg.bwpInactivityTmr)
1322 /* TODO : This is an optional parameter, not filled currently */
1325 /* Fill PDSCH serving cell config */
1326 if(fillPdschServCellCfg(macSpCellCfg.servCellCfg.pdschServCellCfg, \
1327 &servCellCfg->pdschServCellCfg) != ROK)
1329 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1333 /* Fill Initail UL BWP */
1334 if(fillInitialUlBwp(macSpCellCfg.servCellCfg.initUlBwp, \
1335 &servCellCfg->initUlBwp) != ROK)
1337 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1341 servCellCfg->numUlBwpToAdd = macSpCellCfg.servCellCfg.numUlBwpToAdd;
1342 if(servCellCfg->numUlBwpToAdd > MAX_NUM_BWP)
1344 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1345 servCellCfg->numUlBwpToAdd, MAX_NUM_BWP);
1348 for(idx = 0; idx < servCellCfg->numUlBwpToAdd; idx++)
1350 /* TODO : As of now numDlBwpToAdd = 0 */
1352 servCellCfg->firstActvUlBwpId = macSpCellCfg.servCellCfg.firstActvUlBwpId;
1357 /*******************************************************************
1359 * @brief Sends UE configuration to Scheduler
1363 * Function : sendUeReqToSch
1365 * Functionality: sends UE configuration to Scheduler
1367 * @params[in] Pst and Ue configuration
1368 * @return ROK - success
1371 * ****************************************************************/
1373 uint8_t sendUeReqToSch(Pst *pst, SchUeCfg *schUeCfg)
1378 case EVENT_MAC_UE_CREATE_REQ:
1379 FILL_PST_MAC_TO_SCH(schPst, EVENT_ADD_UE_CONFIG_REQ_TO_SCH);
1380 return(*macSchAddUeConfigReqOpts[schPst.selector])(&schPst, schUeCfg);
1382 case EVENT_MAC_UE_RECONFIG_REQ:
1383 FILL_PST_MAC_TO_SCH(schPst, EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH);
1384 return(*macSchModUeConfigReqOpts[schPst.selector])(&schPst,schUeCfg);
1386 DU_LOG("\nERROR --> Invalid Pst received %d", pst->event);
1391 /*******************************************************************
1393 * @brief Fills Sch Drb Qos Information
1397 * Function : fillSchDrbQosInfo
1399 * Functionality: Fills Sch Drb Qos Information
1401 * @params[in] macLcCfg : Logical channel Cfg at MAC
1402 * schLcCfg : LC cfg to fill at scheduler
1403 * @return ROK - success
1406 * ****************************************************************/
1407 void fillSchDrbQosInfo(DrbQosInfo *macDrbQos, SchDrbQosInfo *schDrbQos)
1409 schDrbQos->fiveQiType = macDrbQos->fiveQiType;
1410 if(schDrbQos->fiveQiType == SCH_QOS_NON_DYNAMIC)
1412 schDrbQos->u.nonDyn5Qi.fiveQi = macDrbQos->u.nonDyn5Qi.fiveQi;
1413 schDrbQos->u.nonDyn5Qi.avgWindow = macDrbQos->u.nonDyn5Qi.avgWindow;
1414 schDrbQos->u.nonDyn5Qi.maxDataBurstVol = macDrbQos->u.nonDyn5Qi.maxDataBurstVol;
1415 schDrbQos->u.nonDyn5Qi.priorLevel = macDrbQos->u.nonDyn5Qi.priorLevel;
1417 else if(schDrbQos->fiveQiType == SCH_QOS_DYNAMIC)
1419 schDrbQos->u.dyn5Qi.priorLevel = macDrbQos->u.dyn5Qi.priorLevel;
1420 schDrbQos->u.dyn5Qi.packetDelayBudget = macDrbQos->u.dyn5Qi.packetDelayBudget;
1421 schDrbQos->u.dyn5Qi.packetErrRateScalar= macDrbQos->u.dyn5Qi.packetErrRateScalar;
1422 schDrbQos->u.dyn5Qi.packetErrRateExp = macDrbQos->u.dyn5Qi.packetErrRateExp;
1423 schDrbQos->u.dyn5Qi.fiveQi = macDrbQos->u.dyn5Qi.fiveQi;
1424 schDrbQos->u.dyn5Qi.delayCritical = macDrbQos->u.dyn5Qi.delayCritical;
1425 schDrbQos->u.dyn5Qi.avgWindow = macDrbQos->u.dyn5Qi.avgWindow;
1426 schDrbQos->u.dyn5Qi.maxDataBurstVol = macDrbQos->u.dyn5Qi.maxDataBurstVol;
1428 schDrbQos->ngRanRetPri.priorityLevel = macDrbQos->ngRanRetPri.priorityLevel;
1429 schDrbQos->ngRanRetPri.preEmptionCap = macDrbQos->ngRanRetPri.preEmptionCap;
1430 schDrbQos->ngRanRetPri.preEmptionVul = macDrbQos->ngRanRetPri.preEmptionVul;
1431 schDrbQos->grbQosFlowInfo.maxFlowBitRateDl = macDrbQos->grbQosInfo.maxFlowBitRateDl;
1432 schDrbQos->grbQosFlowInfo.maxFlowBitRateUl = macDrbQos->grbQosInfo.maxFlowBitRateUl;
1433 schDrbQos->grbQosFlowInfo.guarFlowBitRateDl= macDrbQos->grbQosInfo.guarFlowBitRateDl;
1434 schDrbQos->grbQosFlowInfo.guarFlowBitRateUl= macDrbQos->grbQosInfo.guarFlowBitRateUl;
1435 schDrbQos->pduSessionId = macDrbQos->pduSessionId;
1436 schDrbQos->ulPduSessAggMaxBitRate = macDrbQos->ulPduSessAggMaxBitRate;
1439 /*******************************************************************
1441 * @brief Fill SCH UL logical channel configuration
1445 * Function : fillSchUlLcCfg
1447 * Functionality: Fills Sch Ul Lc configuration
1449 * @params[in] macLcCfg : Logical channel Cfg at MAC
1450 * schLcCfg : LC cfg to fill at scheduler
1453 * ****************************************************************/
1455 void fillSchUlLcCfg(SchUlLcCfg *schUlLcCfg, UlLcCfg *macUlLcCfg)
1457 schUlLcCfg->priority= macUlLcCfg->priority;
1458 schUlLcCfg->lcGroup = macUlLcCfg->lcGroup;
1459 schUlLcCfg->schReqId= macUlLcCfg->schReqId;
1460 schUlLcCfg->pbr = macUlLcCfg->pbr;
1461 schUlLcCfg->bsd = macUlLcCfg->bsd;
1464 /*******************************************************************
1466 * @brief Fill logical channel configuration
1470 * Function : fillLogicalChannelCfg
1472 * Functionality: Fill logical channel configuration
1474 * @params[in] macLcCfg : Logical channel Cfg at MAC
1475 * schLcCfg : LC cfg to fill at scheduler
1476 * @return ROK - success
1479 * ****************************************************************/
1480 uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg)
1484 schLcCfg->lcId = macLcCfg->lcId;
1485 schLcCfg->configType = macLcCfg->configType;
1486 schLcCfg->dlLcCfg.lcp = macLcCfg->dlLcCfg.lcp;
1487 fillSchUlLcCfg(&schLcCfg->ulLcCfg, &macLcCfg->ulLcCfg);
1489 if(macLcCfg->drbQos)
1491 if(!schLcCfg->drbQos)
1493 MAC_ALLOC(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
1494 if(!schLcCfg->drbQos)
1496 DU_LOG("\nERROR --> MAC : Memory alloc failed at drbQos at fillLogicalChannelCfg()");
1502 fillSchDrbQosInfo(macLcCfg->drbQos, schLcCfg->drbQos);
1509 schLcCfg->drbQos = NULLP;
1514 if(macLcCfg->snssai)
1516 if(!schLcCfg->snssai)
1518 MAC_ALLOC(schLcCfg->snssai, sizeof(SchSnssai));
1519 if(!schLcCfg->snssai)
1521 DU_LOG("\nERROR --> MAC : Memory alloc failed at snssai at fillLogicalChannelCfg()");
1527 schLcCfg->snssai->sst = macLcCfg->snssai->sst;
1528 for(sdIdx = 0; sdIdx < SD_SIZE; sdIdx++)
1530 schLcCfg->snssai->sd[sdIdx] = macLcCfg->snssai->sd[sdIdx];
1535 schLcCfg->snssai = NULLP;
1536 /*Freeing the previously allocated buffer in case of failure */
1537 if(schLcCfg->drbQos)
1539 MAC_FREE(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
1540 schLcCfg->drbQos = NULLP;
1547 schLcCfg->snssai = NULLP;
1554 /*******************************************************************
1556 * @brief Fills Logical channel Cfg List to Add/Mod/Del
1560 * Function : fillSchLcCfgList
1562 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
1564 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1565 * @return ROK - success
1568 * ****************************************************************/
1570 uint8_t fillSchLcCfgList(SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
1574 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1576 if(fillLogicalChannelCfg(&schUeCfg->schLcCfg[lcIdx], &ueCfg->lcCfgList[lcIdx]) != ROK)
1578 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1586 /*******************************************************************
1588 * @brief Fills and sends UE configuration to Scheduler
1592 * Function : fillSchUeCfg
1594 * Functionality: Fills and sends UE configuration to Scheduler
1596 * @params[in] Ue configuration from DU APP
1597 * @return ROK - success
1600 * ****************************************************************/
1601 uint8_t fillSchUeCfg(Pst *pst, SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
1605 schUeCfg->cellId = ueCfg->cellId;
1606 schUeCfg->crnti = ueCfg->crnti;
1608 /* Copy MAC cell group config */
1609 memset(&schUeCfg->macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
1610 if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg->macCellGrpCfg) != ROK)
1612 DU_LOG("\nERROR --> MAC : fillMacCellGroupCfg() failed");
1616 /* Copy Physical cell group config */
1617 memset(&schUeCfg->phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
1618 if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg->phyCellGrpCfg) != ROK)
1620 DU_LOG("\nERROR --> MAC : fillPhyCellGroupCfg() failed");
1624 /* Copy sp cell config */
1625 memset(&schUeCfg->spCellCfg, 0, sizeof(SchSpCellCfg));
1626 if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg->spCellCfg) != ROK)
1628 DU_LOG("\nERROR --> MAC : fillSpCellCfg() failed");
1632 if(ueCfg->ambrCfg != NULLP)
1634 MAC_ALLOC(schUeCfg->ambrCfg, sizeof(SchAmbrCfg));
1635 if(!schUeCfg->ambrCfg)
1637 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1640 schUeCfg->ambrCfg->ulBr = ueCfg->ambrCfg->ulBr;
1641 schUeCfg->ambrCfg->dlBr = ueCfg->ambrCfg->dlBr;
1644 schUeCfg->ambrCfg = NULLP;
1646 /* Fill DL modulation infor */
1647 schUeCfg->dlModInfo.modOrder = ueCfg->dlModInfo.modOrder;
1648 schUeCfg->dlModInfo.mcsIndex = ueCfg->dlModInfo.mcsIndex;
1649 schUeCfg->dlModInfo.mcsTable = ueCfg->dlModInfo.mcsTable;
1651 /* Fill UL modulation infor */
1652 schUeCfg->ulModInfo.modOrder = ueCfg->ulModInfo.modOrder;
1653 schUeCfg->ulModInfo.mcsIndex = ueCfg->ulModInfo.mcsIndex;
1654 schUeCfg->ulModInfo.mcsTable = ueCfg->ulModInfo.mcsTable;
1656 /* Fill sch Lc Cfg to Add/ Mod/ Del */
1657 ret = fillSchLcCfgList(schUeCfg, ueCfg);
1660 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeCfg()");
1666 /*******************************************************************
1668 * @brief Update UeUlCb Lc List
1672 * Function : updateMacUlCb
1674 * Functionality: Update UeUlCb Lc List
1676 * @params[in] delIdx, UeUlCb pointer
1679 * ****************************************************************/
1681 void updateMacUlCb(uint8_t delIdx, UeUlCb *ulCb)
1685 for(lcIdx = delIdx; lcIdx < ulCb->numUlLc; lcIdx++)
1687 /* Moving the array element to one step ahead */
1688 memcpy(&ulCb->lcCb[lcIdx], &ulCb->lcCb[lcIdx+1], sizeof(UlLcCb));
1689 memset(&ulCb->lcCb[lcIdx+1], 0, sizeof(UlLcCb));
1693 /*******************************************************************
1695 * @brief Update UeDlCb Lc List
1699 * Function : updateMacDlCb
1701 * Functionality: Update UeDlCb Lc List
1703 * @params[in] delIdx, UeDlCb pointer
1706 * ****************************************************************/
1708 void updateMacDlCb(uint8_t delIdx, UeDlCb *dlCb)
1712 for(lcIdx = delIdx; lcIdx < dlCb->numDlLc; lcIdx++)
1714 /* Moving the array element to one step ahead */
1715 memcpy(&dlCb->lcCb[lcIdx], &dlCb->lcCb[lcIdx+1], sizeof(DlLcCb));
1716 memset(&dlCb->lcCb[lcIdx+1], 0, sizeof(DlLcCb));
1720 /*******************************************************************
1722 * @brief Fills Logical channel Cfg List to Add/Mod/Del
1726 * Function : fillMacLcCfgList
1728 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
1730 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1731 * @return ROK - success
1734 * ****************************************************************/
1736 uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCfg *ueCfg)
1738 uint8_t lcIdx, ueLcIdx;
1740 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1742 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
1744 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_ADD)
1746 /*Filling DL LC CB */
1747 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
1748 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
1749 ueCb->dlInfo.numDlLc++;
1750 /*Filling UL LC CB */
1751 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
1752 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
1753 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
1754 ueCb->ulInfo.numUlLc++;
1755 }/*End of Add Config */
1758 //searching for Lc to be Mod
1759 for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++)
1761 if(ueCb->ulInfo.lcCb[ueLcIdx].lcId == ueCfg->lcCfgList[lcIdx].lcId)
1763 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_MOD)
1765 /*Nothing to Modify in DL LC CB */
1766 /*Modify UL LC CB */
1767 ueCb->ulInfo.lcCb[ueLcIdx].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
1768 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d]", ueCfg->lcCfgList[lcIdx].lcId);
1771 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_DEL)
1773 memset(&ueCb->dlInfo.lcCb[ueLcIdx], 0, sizeof(DlLcCb));
1774 (ueCb->dlInfo.numDlLc)--;
1775 updateMacDlCb(ueLcIdx, &ueCb->dlInfo);
1777 memset(&ueCb->ulInfo.lcCb[ueLcIdx], 0, sizeof(UlLcCb));
1778 (ueCb->ulInfo.numUlLc)--;
1779 updateMacUlCb(ueLcIdx, &ueCb->ulInfo);
1780 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", ueCfg->lcCfgList[lcIdx].lcId);
1785 }/*End of Mod Config */
1791 /*******************************************************************
1793 * @brief Fills MAC UE Cb Cfg
1797 * Function : fillMacUeCb
1799 * Functionality: Fills MAC UE Cb Cfg
1801 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1803 * @return ROK - success
1806 * ****************************************************************/
1808 uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx)
1812 ueCb->ueIdx = ueCfg->ueIdx;
1813 ueCb->crnti = ueCfg->crnti;
1814 ueCb->cellCb = macCb.macCell[cellIdx];
1815 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
1816 ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
1817 ueCb->state = UE_STATE_ACTIVE;
1818 /*TODO: To check the bsr value during implementation */
1819 ueCb->bsrTmrCfg.periodicTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer;
1820 ueCb->bsrTmrCfg.retxTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer;
1821 ueCb->bsrTmrCfg.srDelayTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer;
1822 ret = fillMacLcCfgList(ueCb, ueCfg);
1825 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at fillMacUeCb()");
1830 /*******************************************************************
1832 * @brief Function to update Mac Ra Cb
1836 * Function : updateMacRaCb
1838 * Functionality: Function to update Mac Ra Cb
1840 * @params[in] cellIdx, Mac Ue Cb
1841 * @return ROK - success
1844 * ****************************************************************/
1846 uint8_t updateMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
1850 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
1852 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == ueCb->crnti)
1854 ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueIdx];
1861 /*******************************************************************
1863 * @brief Function to delete Mac Ra Cb
1867 * Function : deleteMacRaCb
1869 * Functionality: Function to delete Mac Ra Cb
1871 * @params[in] cellIdx, Mac Ue Cb
1874 * ****************************************************************/
1876 void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
1880 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
1882 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == ueCb->crnti)
1884 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu)
1886 MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
1887 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
1889 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu)
1891 MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \
1892 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize);
1894 memset(&macCb.macCell[cellIdx]->macRaCb[ueIdx], 0, sizeof(MacRaCbInfo));
1901 /*******************************************************************
1903 * @brief Creates UE Cb
1907 * Function : createUeCb
1909 * Functionality: Creates UE Cb
1911 * @params[in] MAC UE Configuration
1912 * @return ROK - success
1915 * ****************************************************************/
1916 uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
1920 if((ueCb->ueIdx == ueCfg->ueIdx) && (ueCb->crnti == ueCfg->crnti)\
1921 &&(ueCb->state == UE_STATE_ACTIVE))
1923 DU_LOG("\nERROR --> MAC : CRNTI %d already configured ", ueCfg->crnti);
1928 memset(ueCb, 0, sizeof(MacUeCb));
1929 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
1932 DU_LOG("\nERROR --> MAC : Failed to create Ue Cb at createUeCb()");
1937 macCb.macCell[cellIdx]->numActvUe++;
1938 updateMacRaCb(cellIdx, ueCb);
1946 /*******************************************************************
1948 * @brief Modify UE Cb Cfg
1952 * Function : modifyUeCb
1954 * Functionality: modify UE Cb
1956 * @params[in] MAC UE Configuration
1957 * @return ROK - success
1960 * ****************************************************************/
1961 uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
1965 if((ueCb->ueIdx == ueCfg->ueIdx) && (ueCb->crnti == ueCfg->crnti)\
1966 &&(ueCb->state == UE_STATE_ACTIVE))
1968 DU_LOG("\nINFO --> MAC : Modifying Ue config Req for CRNTI %d ", ueCfg->crnti);
1969 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
1972 DU_LOG("\nERROR --> MAC : Failed to modify MacUeCb at modifyUeCb()");
1977 deleteMacRaCb(cellIdx, ueCb);
1985 /*******************************************************************
1987 * @brief Creates UE Cb and fills ueCfg
1991 * Function : procMacUeCfgData
1993 * Functionality: Creates UE Cb and fills ueCfg
1995 * @params[in] MAC UE Configuration
1996 * @return ROK - success
1999 * ****************************************************************/
2001 uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg)
2005 MacUeCb *ueCb = NULLP;
2008 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2010 /* Validate cell id */
2011 if(macCb.macCell[cellIdx]->cellId != ueCfg->cellId)
2013 DU_LOG("\nERROR --> MAC : Cell Id %d not configured", ueCfg->cellId);
2017 /* Check if max number of UE configured */
2018 if(macCb.macCell[cellIdx]->numActvUe > MAX_NUM_UE)
2020 DU_LOG("\nERROR --> MAC : Max number of UE [%d] already configured", MAX_NUM_UE);
2024 /* Check if UE already configured */
2025 ueCb = &macCb.macCell[cellIdx]->ueCb[ueCfg->ueIdx -1];
2028 case EVENT_UE_CONFIG_RSP_TO_MAC:
2029 ret = createUeCb(cellIdx, ueCb, ueCfg);
2031 DU_LOG("\nERROR --> MAC: AddUeConfigReq for cellIdx :%d failed in procMacUeCfgData()", cellIdx);
2033 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2034 ret = modifyUeCb(cellIdx, ueCb, ueCfg);
2036 DU_LOG("\nERROR --> MAC: ModifyUeConfigReq for cellIdx :%d failed at procMacUeCfgData()", cellIdx);
2045 /*******************************************************************
2047 * @brief Function to store the UeCfg Data
2051 * Function : copyToTmpData
2053 * Functionality: Function to store the UeCfg Data
2055 * @params[in] MacUeCfg pointer
2056 * @return ROK - success
2059 * ****************************************************************/
2061 uint8_t copyToTmpData(MacUeCfg *ueCfg)
2064 MacUeCfg *tmpData = NULLP;
2066 MAC_ALLOC(tmpData, sizeof(MacUeCfg));
2069 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2072 memcpy(tmpData, ueCfg, sizeof(MacUeCfg));
2073 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2074 macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueIdx-1] = tmpData;
2078 /*******************************************************************
2080 * @brief Handles UE create requst from DU APP
2084 * Function : MacProcUeCreateReq
2086 * Functionality: Handles UE create requst from DU APP
2089 * @return ROK - success
2092 * ****************************************************************/
2093 uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
2097 memset(&schUeCfg, 0, sizeof(SchUeCfg));
2099 DU_LOG("\nINFO --> MAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
2103 /*Storing received ueCfg in ueCfgTmpData */
2104 ret = copyToTmpData(ueCfg);
2107 /*Sending Cfg Req to SCH */
2108 ret = fillSchUeCfg(pst, &schUeCfg, ueCfg);
2110 DU_LOG("\nERROR --> MAC : Failed to fill Sch Ue Cfg at MacProcUeCreateReq()");
2113 /* Fill event and send UE create request to SCH */
2114 ret = sendUeReqToSch(pst, &schUeCfg);
2116 DU_LOG("\nERROR --> MAC : Failed to send UE Create request to SCH");
2121 DU_LOG("\nERROR --> MAC : Failed to store MAC UE CFG ");
2126 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2129 /* FREE shared memory */
2130 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
2135 /*******************************************************************
2137 * @brief Fill and Send UE create response from MAC to DU APP
2141 * Function : MacSendUeCreateRsp
2143 * Functionality: Fill and Send UE create response from MAC to DUAPP
2145 * @params[in] MAC UE create result
2146 * SCH UE create response
2147 * @return ROK - success
2150 * ****************************************************************/
2151 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2153 MacUeCfgRsp *cfgRsp;
2156 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
2159 DU_LOG("\nERROR --> MAC: Memory allocation for UE config response failed");
2163 /* Filling UE Config response */
2164 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
2165 cfgRsp->cellId = schCfgRsp->cellId;
2166 cfgRsp->ueIdx = schCfgRsp->ueIdx;
2167 cfgRsp->result = result;
2169 /* Fill Post structure and send UE Create response*/
2170 memset(&rspPst, 0, sizeof(Pst));
2171 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CREATE_RSP);
2172 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2175 /*******************************************************************
2177 * @brief Fill and Send UE Reconfig response from MAC to DU APP
2181 * Function : MacSendUeReconfigRsp
2183 * Functionality: Fill and Send UE Reconfig response from MAC to DUAPP
2185 * @params[in] MAC UE create result
2186 * SCH UE create response
2187 * @return ROK - success
2190 * ****************************************************************/
2191 uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2193 MacUeCfgRsp *cfgRsp;
2196 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
2199 DU_LOG("\nERROR --> MAC: Memory allocation for UE Reconfig response failed");
2203 /* Filling UE Config response */
2204 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
2205 cfgRsp->cellId = schCfgRsp->cellId;
2206 cfgRsp->ueIdx = schCfgRsp->ueIdx;
2207 cfgRsp->result = result;
2209 /* Fill Post structure and send UE Create response*/
2210 memset(&rspPst, 0, sizeof(Pst));
2211 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RECONFIG_RSP);
2212 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2215 /*******************************************************************
2217 * @brief Function to return Mac Ue Cfg pointer
2221 * Function : getMacUeCfg
2224 * Function to return Mac Ue Cfg pointer
2226 * @params[in] cellIdx, ueIdx
2228 * @return MacUeCfg pointer - success
2231 * ****************************************************************/
2233 MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t ueIdx)
2235 MacUeCfg *ueCfg = NULLP;
2236 if(macCb.macCell[cellIdx])
2238 ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[ueIdx-1];
2242 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeCfg()");
2247 /*******************************************************************
2249 * @brief Processes UE create response from scheduler
2253 * Function : MacProcSchUeCfgRsp
2256 * Processes UE create response from scheduler
2257 * Sends UE create response to DU APP
2259 * @params[in] Pst : Post structure
2260 * schCfgRsp : Scheduler UE cfg response
2261 * @return ROK - success
2264 * ****************************************************************/
2265 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
2267 uint8_t result = MAC_DU_APP_RSP_NOK;
2270 MacUeCfg *ueCfg = NULLP;
2272 GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
2273 ueCfg = getMacUeCfg(cellIdx, schCfgRsp->ueIdx);
2276 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
2282 case EVENT_UE_CONFIG_RSP_TO_MAC:
2284 if(schCfgRsp->rsp != RSP_NOK)
2286 DU_LOG("\nINFO --> MAC: SCH UeConfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2289 ret = procMacUeCfgData(pst, ueCfg);
2292 result = MAC_DU_APP_RSP_OK;
2298 DU_LOG("\nERROR --> MAC: SCH UeConfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2300 ret = MacSendUeCreateRsp(result, schCfgRsp);
2304 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2306 if(schCfgRsp->rsp != RSP_NOK)
2308 DU_LOG("\nINFO --> MAC: SCH UeReconfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2311 ret = procMacUeCfgData(pst, ueCfg);
2314 result = MAC_DU_APP_RSP_OK;
2320 DU_LOG("\nERROR --> MAC: SCH UeReconfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2322 ret = MacSendUeReconfigRsp(result, schCfgRsp);
2329 MAC_FREE(ueCfg, sizeof(MacUeCfg));
2335 /*******************************************************************
2337 * @brief Handles UE Reconfig requst from DU APP
2341 * Function : MacProcUeReconfigReq
2343 * Functionality: Handles UE Reconfig requst from DU APP
2346 * @return ROK - success
2349 * ****************************************************************/
2350 uint8_t MacProcUeReconfigReq(Pst *pst, MacUeCfg *ueCfg)
2354 memset(&schUeCfg, 0, sizeof(SchUeCfg));
2356 DU_LOG("\nINFO --> MAC : UE Reconfig Request for CRNTI[%d]", ueCfg->crnti);
2360 /*Storing received ueCfg in ueCfgTmpData */
2361 ret = copyToTmpData(ueCfg);
2364 /*Sending Cfg Req to SCH */
2365 ret = fillSchUeCfg(pst, &schUeCfg, ueCfg);
2367 DU_LOG("\nERROR --> MAC : Failed to fill sch Ue Cfg at MacProcUeReconfigReq()");
2370 /* Fill event and send UE create request to SCH */
2371 ret = sendUeReqToSch(pst, &schUeCfg);
2373 DU_LOG("\nERROR --> MAC : Failed to send UE Reconfig Request to SCH");
2378 DU_LOG("\nERROR --> MAC : Failed to store MAC UE Cb ");
2383 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2386 /* FREE shared memory */
2387 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
2392 /**********************************************************************
2394 **********************************************************************/