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 MacSchUeCreateReqFunc macSchUeCreateReqOpts[] =
34 packMacSchUeCreateReq, /* packing for loosely coupled */
35 MacSchUeCreateReq, /* packing for tightly coupled */
36 packMacSchUeCreateReq /* 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 MacSchUeReconfigReqFunc macSchUeReconfigReqOpts[] =
48 packMacSchUeReconfigReq, /* packing for loosely coupled */
49 MacSchUeReconfigReq, /* packing for tightly coupled */
50 packMacSchUeReconfigReq /* 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("\nMAC : 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("\nMAC : 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("\nMAC :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("\nMAC :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("\nMAC :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("\nMAC :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("\nMAC : 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 Fills initail UL BWP config to send to scheduler
305 * Function : fillInitialUlBwp
307 * Functionality: Fills initail UL BWP config to send to sch
309 * @params[in] macInitUlBwp : Initial UL BWP cfg at MAC
310 * schInitUlBwp : Initial UL BWP cfg to be filled
311 * @return ROK - success
314 * ****************************************************************/
315 uint8_t fillInitialUlBwp(InitialUlBwp macInitUlBwp, SchInitialUlBwp *schInitUlBwp)
317 schInitUlBwp->pucchCfgPres = macInitUlBwp.pucchPresent;
318 if(schInitUlBwp->pucchCfgPres)
320 /* TODO : Optional parameter */
323 schInitUlBwp->puschCfgPres = macInitUlBwp.puschPresent;
324 if(schInitUlBwp->puschCfgPres)
326 if(fillInitalUlBwpPuschCfg(macInitUlBwp.puschCfg, &schInitUlBwp->puschCfg) != ROK)
328 DU_LOG("\nMAC : fillInitalUlBwpPuschCfg() failed");
335 /*******************************************************************
337 * @brief Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
341 * Function : fillInitDlBwpPdcchCfg
344 * Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
346 * @params[in] macPdcchCfg : Inital DL BWP PDCCH cfg in MAC
347 * schPdcchCfg : Inital DL BWP PDCCH cfg to be filled
348 * @return ROK - success
351 * ****************************************************************/
352 uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchCfg)
356 /* Fill CORESET info */
357 schPdcchCfg->numCRsetToAddMod = macPdcchCfg.numCRsetToAddMod;
358 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
360 DU_LOG("\nMAC : Number of CORESET to ADD/MOD [%d] exceeds max limit [%d]",\
361 schPdcchCfg->numCRsetToAddMod, MAX_NUM_CRSET);
365 for(idx = 0; idx < schPdcchCfg->numCRsetToAddMod; idx++)
367 schPdcchCfg->cRSetToAddModList[idx].cRSetId = \
368 macPdcchCfg.cRSetToAddModList[idx].cRSetId;
369 memcpy(&schPdcchCfg->cRSetToAddModList[idx].freqDomainRsrc,\
370 &macPdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
371 schPdcchCfg->cRSetToAddModList[idx].duration = \
372 macPdcchCfg.cRSetToAddModList[idx].duration;
373 schPdcchCfg->cRSetToAddModList[idx].cceRegMappingType = \
374 macPdcchCfg.cRSetToAddModList[idx].cceRegMappingType;
375 schPdcchCfg->cRSetToAddModList[idx].precoderGranularity = \
376 macPdcchCfg.cRSetToAddModList[idx].precoderGranularity;
377 schPdcchCfg->cRSetToAddModList[idx].dmrsScramblingId = \
378 macPdcchCfg.cRSetToAddModList[idx].dmrsScramblingId;
381 schPdcchCfg->numCRsetToRel = macPdcchCfg.numCRsetToRel;
382 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
384 DU_LOG("\nMAC : Number of CORESET to release [%d] exceeds max limit [%d]",\
385 schPdcchCfg->numCRsetToRel, MAX_NUM_CRSET);
389 for(idx = 0; idx < schPdcchCfg->numCRsetToRel; idx++)
394 /* Fill Search space info */
395 schPdcchCfg->numSearchSpcToAddMod = macPdcchCfg.numSearchSpcToAddMod;
396 if(schPdcchCfg->numSearchSpcToAddMod > MAX_NUM_SEARCH_SPC)
398 DU_LOG("\nMAC : Number of search space to ADD/MOD [%d] exceeds max [%d]", \
399 schPdcchCfg->numSearchSpcToAddMod, MAX_NUM_SEARCH_SPC);
402 for(idx = 0; idx < schPdcchCfg->numSearchSpcToAddMod; idx++)
404 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceId = \
405 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
406 schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
407 macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
408 schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
409 macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
410 memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
411 &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
412 MONITORING_SYMB_WITHIN_SLOT_SIZE);
413 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1 = \
414 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1;
415 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2 = \
416 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2;
417 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4 = \
418 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4;
419 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8 = \
420 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8;
421 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16 = \
422 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16;
423 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceType = \
424 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceType;
425 schPdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat = \
426 macPdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat;
429 schPdcchCfg->numSearchSpcToRel = macPdcchCfg.numSearchSpcToRel;
430 if(schPdcchCfg->numSearchSpcToRel > MAX_NUM_SEARCH_SPC)
432 DU_LOG("\nMAC : Number of search space to release [%d] exceeds max [%d]", \
433 schPdcchCfg->numSearchSpcToRel, MAX_NUM_SEARCH_SPC);
436 for(idx = 0; idx < schPdcchCfg->numSearchSpcToRel; idx++)
444 /*******************************************************************
446 * @brief Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
450 * Function : fillInitDlBwpPdschCfg
453 * Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
455 * @params[in] macPdschCfg : Inital DL BWP PDSCH cfg at MAC
456 * schPdschCfg : Inital DL BWP PDSCH cfg to be filled
457 * @return ROK - success
460 * ****************************************************************/
461 uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschCfg)
465 schPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
466 macPdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
467 schPdschCfg->resourceAllocType = macPdschCfg.resourceAllocType;
468 schPdschCfg->numTimeDomRsrcAlloc = macPdschCfg.numTimeDomRsrcAlloc;
469 if(schPdschCfg->numTimeDomRsrcAlloc > MAX_NUM_DL_ALLOC)
471 DU_LOG("\nMAC : Number of time domain resource allocation [%d], exceeds\
472 max limit [%d]", schPdschCfg->numTimeDomRsrcAlloc, MAX_NUM_DL_ALLOC);
476 for(idx = 0; idx < schPdschCfg->numTimeDomRsrcAlloc; idx++)
478 schPdschCfg->timeDomRsrcAllociList[idx].mappingType = \
479 macPdschCfg.timeDomRsrcAllociList[idx].mappingType;
480 schPdschCfg->timeDomRsrcAllociList[idx].startSymbol = \
481 macPdschCfg.timeDomRsrcAllociList[idx].startSymbol;
482 schPdschCfg->timeDomRsrcAllociList[idx].symbolLength = \
483 macPdschCfg.timeDomRsrcAllociList[idx].symbolLength;
486 schPdschCfg->rbgSize = macPdschCfg.rbgSize;
487 schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
488 schPdschCfg->bundlingType = macPdschCfg.bundlingType;
489 if(schPdschCfg->bundlingType == STATIC_BUNDLING_TYPE)
491 schPdschCfg->bundlingInfo.SchStaticBundling.size = macPdschCfg.bundlingInfo.StaticBundling.size;
493 else if(schPdschCfg->bundlingType == DYNAMIC_BUNDLING_TYPE)
495 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet1 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet1;
496 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet2 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet2;
501 /*******************************************************************
503 * @brief Fill Initial DL BWP for SCH UE config
507 * Function : fillInitialDlBwp
509 * Functionality: Fill Initial DL BWP for SCH UE config
511 * @params[in] macInitDlBwp : Inital DL BWP cfg at MAC
512 * schInitDlBwp : Inital DL BWP cfg to be filled
513 * @return ROK - success
516 * ****************************************************************/
517 uint8_t fillInitialDlBwp(InitialDlBwp macInitDlBwp, SchInitalDlBwp *schInitDlBwp)
519 schInitDlBwp->pdcchCfgPres = macInitDlBwp.pdcchPresent;
520 if(schInitDlBwp->pdcchCfgPres)
522 if(fillInitDlBwpPdcchCfg(macInitDlBwp.pdcchCfg, &schInitDlBwp->pdcchCfg) != ROK)
524 DU_LOG("\nMAC : fillInitDlBwpPdcchCfg() failed");
529 schInitDlBwp->pdschCfgPres = macInitDlBwp.pdschPresent;
530 if(schInitDlBwp->pdschCfgPres)
532 if(fillInitDlBwpPdschCfg(macInitDlBwp.pdschCfg,&schInitDlBwp->pdschCfg) != ROK)
534 DU_LOG("\nMAC : fillInitDlBwpPdschCfg() failed");
541 /*******************************************************************
543 * @brief Fills Sp Cell config to be sent to scheduler
547 * Function : fillSpCellCfg
549 * Functionality: Fills Sp Cell config to be sent to scheduler
551 * @params[in] macSpCellCfg : SP cell cfg at MAC
552 * schSpCellCfg : SP cell cfg to be filled
553 * @return ROK - success
556 * ****************************************************************/
557 uint8_t fillSpCellCfg(SpCellCfg macSpCellCfg, SchSpCellCfg *schSpCellCfg)
560 SchServCellCfgInfo *servCellCfg;
562 schSpCellCfg->servCellIdx = macSpCellCfg.servCellIdx;
563 servCellCfg = &schSpCellCfg->servCellCfg;
565 /* Fill initial DL BWP */
566 if(fillInitialDlBwp(macSpCellCfg.servCellCfg.initDlBwp, \
567 &servCellCfg->initDlBwp) != ROK )
569 DU_LOG("\nMAC : fillInitialDlBwp() failed");
573 servCellCfg->numDlBwpToAdd = macSpCellCfg.servCellCfg.numDlBwpToAdd;
574 if(servCellCfg->numDlBwpToAdd > MAX_NUM_BWP)
576 DU_LOG("\nMAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
577 servCellCfg->numDlBwpToAdd, MAX_NUM_BWP);
580 for(idx = 0; idx < servCellCfg->numDlBwpToAdd; idx++)
582 /* TODO : As of now numDlBwpToAdd = 0 */
585 servCellCfg->firstActvDlBwpId = macSpCellCfg.servCellCfg.firstActvDlBwpId;
586 servCellCfg->defaultDlBwpId = macSpCellCfg.servCellCfg.defaultDlBwpId;
587 servCellCfg->bwpInactivityTmr = NULL;
588 if(macSpCellCfg.servCellCfg.bwpInactivityTmr)
590 /* TODO : This is an optional parameter, not filled currently */
593 /* Fill PDSCH serving cell config */
594 if(fillPdschServCellCfg(macSpCellCfg.servCellCfg.pdschServCellCfg, \
595 &servCellCfg->pdschServCellCfg) != ROK)
597 DU_LOG("\nMAC : fillPdschServCellCfg() failed");
601 /* Fill Initail UL BWP */
602 if(fillInitialUlBwp(macSpCellCfg.servCellCfg.initUlBwp, \
603 &servCellCfg->initUlBwp) != ROK)
605 DU_LOG("\nMAC : fillInitialUlBwp() failed");
609 servCellCfg->numUlBwpToAdd = macSpCellCfg.servCellCfg.numUlBwpToAdd;
610 if(servCellCfg->numUlBwpToAdd > MAX_NUM_BWP)
612 DU_LOG("\nMAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
613 servCellCfg->numUlBwpToAdd, MAX_NUM_BWP);
616 for(idx = 0; idx < servCellCfg->numUlBwpToAdd; idx++)
618 /* TODO : As of now numDlBwpToAdd = 0 */
620 servCellCfg->firstActvUlBwpId = macSpCellCfg.servCellCfg.firstActvUlBwpId;
626 /*******************************************************************
628 * @brief Fill logical channel configuration
632 * Function : fillLogicalChannelCfg
634 * Functionality: Fill logical channel configuration
636 * @params[in] macLcCfg : Logical channel Cfg at MAC
637 * schLcCfg : LC cfg to fill at scheduler
638 * @return ROK - success
641 * ****************************************************************/
642 uint8_t fillLogicalChannelCfg(LcCfg macLcCfg, SchLcCfg *schLcCfg)
644 schLcCfg->lcId = macLcCfg.lcId;
645 schLcCfg->dlLcCfg.lcp = macLcCfg.dlLcCfg.lcp;
647 schLcCfg->drbQos = NULL;
650 /* TODO : Optional Parameter */
653 schLcCfg->snssai = NULL;
656 /* TODO : Optional Parameter */
662 /*******************************************************************
664 * @brief Fills and sends UE configuration to Scheduler
668 * Function : sendAddUeCreateReqToSch
670 * Functionality: Fills and sends UE configuration to Scheduler
672 * @params[in] Ue configuration from DU APP
673 * @return ROK - success
676 * ****************************************************************/
677 uint8_t sendAddUeCreateReqToSch(MacUeCfg *ueCfg)
683 schUeCfg.cellId = ueCfg->cellId;
684 schUeCfg.crnti = ueCfg->crnti;
686 /* Copy MAC cell group config */
687 memset(&schUeCfg.macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
688 if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg.macCellGrpCfg) != ROK)
690 DU_LOG("\nMAC : fillMacCellGroupCfg() failed");
694 /* Copy Physical cell group config */
695 memset(&schUeCfg.phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
696 if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg.phyCellGrpCfg) != ROK)
698 DU_LOG("\nMAC : fillPhyCellGroupCfg() failed");
702 /* Copy sp cell config */
703 memset(&schUeCfg.spCellCfg, 0, sizeof(SchSpCellCfg));
704 if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg.spCellCfg) != ROK)
706 DU_LOG("\nMAC : fillSpCellCfg() failed");
710 schUeCfg.aggrMaxBitRate = NULL;
711 if(ueCfg->maxAggrBitRate != NULL)
714 MAC_ALLOC(schUeCfg.aggrMaxBitRate, sizeof(SchAggrMaxBitRate));
715 if(!schUeCfg.aggrMaxBitRate)
717 DU_LOG("\nMAC : Memory allocation failed in sendAddUeCreateReqToSch");
720 schUeCfg.aggrMaxBitRate->ulBitRate = ueCfg->maxAggrBitRate->ulBits;
721 schUeCfg.aggrMaxBitRate->dlBitRate = ueCfg->maxAggrBitRate->dlBits;
724 schUeCfg.numLc = ueCfg->numLcs;
725 if(schUeCfg.numLc > MAX_NUM_LC)
727 DU_LOG("\nMAC : Number of Logical channels %d exceeds max limit %d",\
728 schUeCfg.numLc, MAX_NUM_LC);
730 for(idx = 0; idx < schUeCfg.numLc; idx++)
732 if(fillLogicalChannelCfg(ueCfg->lcCfgList[idx], &schUeCfg.lcCfgList[idx]) != ROK)
734 DU_LOG("\nMAC : fillLogicalChannelCfg() failed");
739 /* Fill event and send UE create request to SCH */
740 FILL_PST_MAC_TO_SCH(pst, EVENT_UE_CONFIG_REQ_TO_SCH);
741 return(*macSchUeCreateReqOpts[pst.selector])(&pst, &schUeCfg);
744 /*******************************************************************
746 * @brief Creates UE Cb and fills ueCfg
750 * Function : createUeCb
752 * Functionality: Creates UE Cb and fills ueCfg
754 * @params[in] MAC UE Configuration
755 * @return ROK - success
758 * ****************************************************************/
759 uint8_t createUeCb(MacUeCfg *ueCfg)
761 uint16_t ueIdx, lcIdx, cellIdx;
764 GET_CELL_IDX(ueCfg->cellId, cellIdx);
766 /* Validate cell id */
767 if(macCb.macCell[cellIdx]->cellId != ueCfg->cellId)
769 DU_LOG("\nMAC : Cell Id %d not configured", ueCfg->cellId);
773 /* Check if max number of UE configured */
774 if(macCb.macCell[cellIdx]->numActvUe > MAX_NUM_UE)
776 DU_LOG("MAC : Max number of UE [%d] already configured", MAX_NUM_UE);
780 /* Check if UE already configured */
781 ueCb = &macCb.macCell[cellIdx]->ueCb[ueCfg->ueIdx -1];
784 if((ueCb->ueIdx == ueCfg->ueIdx) && (ueCb->crnti == ueCfg->crnti) &&\
785 (ueCb->state == UE_STATE_ACTIVE))
787 DU_LOG("\n MAC : CRNTI %d already configured ", ueCfg->crnti);
792 /* Fill received Ue Configuration in UeCb */
793 memset(ueCb, 0, sizeof(MacUeCb));
795 ueCb->crnti = ueCfg->crnti;
796 ueCb->cellCb = macCb.macCell[cellIdx];
797 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
798 ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
799 ueCb->state = UE_STATE_ACTIVE;
802 switch(ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer)
805 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_1MS;
808 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_5MS;
811 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_10MS;
814 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_16MS;
817 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_20MS;
820 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_32MS;
823 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_40MS;
826 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_60MS;
829 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_80MS;
832 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_128MS;
835 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_160MS;
838 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_320MS;
841 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_640MS;
844 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_1280MS;
847 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_2560MS;
850 DU_LOG("\nMAC : Invalid BSR Periodic Timer");
854 switch(ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer)
857 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_10MS;
860 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_20MS;
863 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_40MS;
866 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_80MS;
869 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_160MS;
872 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_320MS;
875 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_640MS;
878 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_1280MS;
881 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_2560MS;
884 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_5120MS;
887 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_10240MS;
890 DU_LOG("\nMAC : Invalid BSR retransmission timer");
894 switch(ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer)
897 ueCb->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR_20MS;
900 ueCb->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR_40MS;
903 ueCb->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR_64MS;
906 ueCb->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR_128MS;
909 ueCb->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR_512MS;
912 ueCb->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR_1024MS;
915 ueCb->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR_2560MS;
918 DU_LOG("\nMAC : Invalid SR delay timer");
923 if(ueCfg->numLcs > MAX_NUM_LC)
925 DU_LOG("\nMAC : Number of LC to configure[%d] exceeds limit[%d]",\
926 ueCfg->numLcs, MAX_NUM_LC);
930 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
932 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
933 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
934 ueCb->dlInfo.numDlLc++;
938 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
940 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == ueCb->crnti)
942 ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueIdx];
947 macCb.macCell[cellIdx]->numActvUe++;
952 /*******************************************************************
954 * @brief Handles UE create requst from DU APP
958 * Function : MacProcUeCreateReq
960 * Functionality: Handles UE create requst from DU APP
963 * @return ROK - success
966 * ****************************************************************/
967 uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
971 DU_LOG("\nMAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
975 ret = createUeCb(ueCfg);
978 ret = sendAddUeCreateReqToSch(ueCfg);
981 DU_LOG("\nMAC : Failed to send UE Create request to scheduler");
986 DU_LOG("\nMAC : Failed to create MAC UE Cb ");
991 DU_LOG("\nMAC : MAC UE Create request processing failed");
994 /* FREE shared memory */
995 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
1000 /*******************************************************************
1002 * @brief Fill and Send UE create response from MAC to DU APP
1006 * Function : MacSendUeCreateRsp
1008 * Functionality: Fill and Send UE create response from MAC to DUAPP
1010 * @params[in] MAC UE create result
1011 * SCH UE create response
1012 * @return ROK - success
1015 * ****************************************************************/
1016 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
1018 MacUeCfgRsp *cfgRsp;
1021 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
1024 DU_LOG("\nMAC: Memory allocation for UE config response failed");
1028 /* Filling UE Config response */
1029 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
1030 cfgRsp->cellId = schCfgRsp->cellId;
1031 cfgRsp->ueIdx = schCfgRsp->ueIdx;
1032 cfgRsp->result = result;
1034 /* Fill Post structure and send UE Create response*/
1035 memset(&rspPst, 0, sizeof(Pst));
1036 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CONFIG_RSP);
1037 return MacDuUeCfgRspOpts[rspPst.selector](&rspPst, cfgRsp);
1041 /*******************************************************************
1043 * @brief Processes UE create response from scheduler
1047 * Function : MacProcSchUeCfgRsp
1050 * Processes UE create response from scheduler
1051 * Sends UE create response to DU APP
1053 * @params[in] Pst : Post structure
1054 * schCfgRsp : Scheduler UE cfg response
1055 * @return ROK - success
1058 * ****************************************************************/
1059 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
1061 uint8_t result = MAC_DU_APP_RSP_NOK;
1065 GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
1067 if(schCfgRsp->rsp == RSP_NOK)
1069 DU_LOG("\nMAC : SCH UE Create Response : FAILURE [CRNTI %d]", schCfgRsp->crnti);
1070 memset(&macCb.macCell[cellIdx]->ueCb[schCfgRsp->ueIdx -1], 0, sizeof(MacUeCb));
1071 macCb.macCell[cellIdx]->numActvUe--;
1072 result = MAC_DU_APP_RSP_NOK;
1076 DU_LOG("\nMAC : SCH UE Create Response : SUCCESS [CRNTI %d]", schCfgRsp->crnti);
1077 result = MAC_DU_APP_RSP_OK;
1079 ret = MacSendUeCreateRsp(result, schCfgRsp);
1083 /*******************************************************************
1085 * @brief Handles UE Reconfig requst from DU APP
1089 * Function : MacProcUeReconfigReq
1091 * Functionality: Handles UE Reconfig requst from DU APP
1094 * @return ROK - success
1097 * ****************************************************************/
1098 uint8_t MacProcUeReconfigReq(Pst *pst, MacUeCfg *ueCfg)
1105 /**********************************************************************
1107 **********************************************************************/