1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
18 /* This file stores handler for MAC and SCH configuration requests */
19 /* header include files (.h) */
20 #include "common_def.h"
23 #include "du_app_mac_inf.h"
24 #include "mac_sch_interface.h"
25 #include "lwr_mac_upr_inf.h"
27 #include "rlc_mac_inf.h"
28 #include "mac_upr_inf_api.h"
30 #include "lwr_mac_fsm.h"
31 #include "mac_utils.h"
32 #include "lwr_mac_phy.h"
34 uint8_t ssbPeriodicity[6] = {5, 10, 20, 40, 80, 160};
36 uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg);
38 packMacCellCfgConfirm packMacCellCfmOpts[] =
40 packMacCellCfgCfm, /* packing for loosely coupled */
41 duHandleMacCellCfgCfm, /* packing for tightly coupled */
42 packMacCellCfgCfm, /* packing for light weight loosly coupled */
45 SchCellCfgFunc SchCellCfgOpts[] =
47 packSchCellCfg, /* packing for loosely coupled */
48 SchHdlCellCfgReq, /* packing for tightly coupled */
49 packSchCellCfg /* packing for light weight loosly coupled */
52 MacSchCellDeleteReqFunc macSchCellDeleteReqOpts[]=
54 packMacSchCellDeleteReq, /* packing for loosely coupled */
55 MacSchCellDeleteReq, /* packing for tightly coupled */
56 packMacSchCellDeleteReq /* packing for light weight loosely coupled */
59 MacDuCellDeleteRspFunc macDuCellDeleteRspOpts[] =
61 packDuMacCellDeleteRsp, /* packing for loosely coupled */
62 DuProcMacCellDeleteRsp, /* packing for tightly coupled */
63 packDuMacCellDeleteRsp /* packing for light weight loosly coupled */
66 MacDuSliceCfgRspFunc macDuSliceCfgRspOpts[] =
68 packDuMacSliceCfgRsp, /* packing for loosely coupled */
69 DuProcMacSliceCfgRsp, /* packing for tightly coupled */
70 packDuMacSliceCfgRsp /* packing for light weight loosly coupled */
73 MacDuSliceReCfgRspFunc macDuSliceReCfgRspOpts[] =
75 packDuMacSliceReCfgRsp, /* packing for loosely coupled */
76 DuProcMacSliceReCfgRsp, /* packing for tightly coupled */
77 packDuMacSliceReCfgRsp /* packing for light weight loosly coupled */
81 * @brief Layer Manager Configuration request handler for Scheduler
85 * Function : MacSchGenCfgReq
87 * This function receives general configurations for Scheduler
88 * from DU APP and forwards to Scheduler.
90 * @param[in] Pst *pst, the post structure
91 * @param[in] RgMngmt *cfg, the configuration parameter's structure
95 uint8_t MacSchGenCfgReq(Pst *pst, RgMngmt *cfg)
99 printf("\nReceived Scheduler gen config at MAC");
100 memset(&schPst, 0, sizeof(Pst));
101 FILL_PST_MAC_TO_SCH(schPst, EVENT_SCH_GEN_CFG);
102 SchProcGenCfgReq(&schPst, cfg);
108 * @brief Layer Manager Configuration response from Scheduler
112 * Function : SchSendCfgCfm
114 * This function sends general configurations response from
115 * Scheduler to DU APP.
117 * @param[in] Pst *pst, the post structure
118 * @param[in] RgMngmt *cfm, the configuration confirm structure
122 uint8_t SchSendCfgCfm(Pst *pst, RgMngmt *cfm)
124 DU_LOG("\nDEBUG --> Sending Scheduler config confirm to DU APP");
125 pst->dstEnt = ENTDUAPP;
128 pst->selector = ODU_SELECTOR_LC;
129 RgMiLrgSchCfgCfm(pst, cfm);
135 * @brief Layer Manager Configuration request handler.
139 * Function : MacProcCellCfgReq
141 * This function handles the gNB and cell configuration
142 * request received from DU APP.
143 * This API unapcks and forwards the config towards SCH
145 * @param[in] Pst *pst
146 * @param[in] MacCellCfg *macCellCfg
150 uint8_t MacProcCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
154 uint8_t ret = ROK, sliceIdx = 0;
155 MacCellCb *macCellCb;
157 memset((uint8_t *)&cfmPst, 0, sizeof(Pst));
159 MAC_ALLOC(macCellCb, sizeof(MacCellCb));
160 if(macCellCb == NULLP)
162 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of macCellCfg\n");
165 memset(macCellCb, 0, sizeof(MacCellCb));
167 GET_CELL_IDX(macCellCfg->cellId, cellIdx);
168 macCb.macCell[cellIdx] = macCellCb;
169 macCb.macCell[cellIdx]->cellId = macCellCfg->cellId;
170 memcpy(&macCb.macCell[cellIdx]->macCellCfg, macCellCfg, sizeof(MacCellCfg));
172 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
173 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
174 if(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu == NULLP)
176 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of sib1Pdu of macCellCfg\n");
179 memcpy(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, macCellCfg->sib1Cfg.sib1Pdu, \
180 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
182 macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice = macCellCfg->plmnInfoList.numSupportedSlice;
183 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice\
185 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai == NULLP)
187 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
191 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai)
193 for(sliceIdx=0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++)
195 if(macCellCfg->plmnInfoList.snssai[sliceIdx])
197 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
198 if(!macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx])
200 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
203 memcpy(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx],\
209 /* Send cell cfg to scheduler */
210 ret = MacSchCellCfgReq(pst, macCellCfg);
213 MacCellCfgCfm macCellCfgCfm;
214 macCellCfgCfm.rsp = RSP_NOK;
215 macCellCfgCfm.cellId = macCellCfg->cellId;
217 FILL_PST_MAC_TO_DUAPP(cfmPst, EVENT_MAC_CELL_CONFIG_CFM);
218 cfmPst.selector = ODU_SELECTOR_LC;
220 ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
224 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macCellCfg ,sizeof(MacCellCfg));
227 } /* end of MacProcCellCfgReq */
230 * @brief Layer Manager Configuration request handler.
234 * Function : MacSchCellCfgReq
236 * This function sends cell configuration to SCH
238 * @param[in] Pst *pst
239 * @param[in] MacCellCfg *macCellCfg
243 uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
245 SchCellCfg schCellCfg;
247 uint8_t ssbMaskIdx = 0, rsrcListIdx = 0, ret=0, sliceIdx=0;
249 memset(&cfgPst, 0, sizeof(Pst));
250 memset(&schCellCfg, 0, sizeof(SchCellCfg));
251 schCellCfg.cellId = macCellCfg->cellId;
252 schCellCfg.phyCellId = macCellCfg->phyCellId;
253 schCellCfg.numerology = macCellCfg->numerology;
254 schCellCfg.dupMode = macCellCfg->dupType;
255 schCellCfg.bandwidth = macCellCfg->dlCarrCfg.bw;
256 schCellCfg.dlFreq = macCellCfg->dlCarrCfg.freq;
257 schCellCfg.ulFreq = macCellCfg->ulCarrCfg.freq;
259 /* fill ssb scheduler parameters */
260 schCellCfg.ssbSchCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
261 schCellCfg.ssbSchCfg.scsCommon = macCellCfg->ssbCfg.scsCmn;
262 schCellCfg.ssbSchCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
263 schCellCfg.ssbSchCfg.ssbPeriod = ssbPeriodicity[macCellCfg->ssbCfg.ssbPeriod];
264 schCellCfg.ssbSchCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
265 for(ssbMaskIdx=0; ssbMaskIdx<SSB_MASK_SIZE; ssbMaskIdx++)
267 schCellCfg.ssbSchCfg.nSSBMask[ssbMaskIdx] = macCellCfg->ssbCfg.ssbMask[ssbMaskIdx];
269 schCellCfg.ssbSchCfg.totNumSsb = countSetBits(schCellCfg.ssbSchCfg.nSSBMask[0]);
271 /* fill SIB1 scheduler parameters */
272 schCellCfg.sib1SchCfg.sib1PduLen = macCellCfg->sib1Cfg.sib1PduLen;
273 schCellCfg.sib1SchCfg.sib1RepetitionPeriod = macCellCfg->sib1Cfg.sib1RepetitionPeriod;
274 schCellCfg.sib1SchCfg.coresetZeroIndex = macCellCfg->sib1Cfg.coresetZeroIndex;
275 schCellCfg.sib1SchCfg.searchSpaceZeroIndex = macCellCfg->sib1Cfg.searchSpaceZeroIndex;
276 schCellCfg.sib1SchCfg.sib1Mcs = macCellCfg->sib1Cfg.sib1Mcs;
277 schCellCfg.sib1SchCfg.pageCfg.numPO = macCellCfg->sib1Cfg.pagingCfg.numPO;
278 schCellCfg.sib1SchCfg.pageCfg.poPresent = macCellCfg->sib1Cfg.pagingCfg.poPresent;
280 if(schCellCfg.sib1SchCfg.pageCfg.poPresent)
282 memcpy(schCellCfg.sib1SchCfg.pageCfg.pagingOcc, macCellCfg->sib1Cfg.pagingCfg.pagingOcc, MAX_PO_PER_PF);
285 /* fill RACH config params */
286 schCellCfg.schRachCfg.prachCfgIdx = macCellCfg->prachCfg.prachCfgIdx;
287 schCellCfg.schRachCfg.prachSubcSpacing = \
288 macCellCfg->prachCfg.prachSubcSpacing;
289 schCellCfg.schRachCfg.msg1FreqStart = macCellCfg->prachCfg.msg1FreqStart;
290 schCellCfg.schRachCfg.msg1Fdm = macCellCfg->prachCfg.msg1Fdm;
291 schCellCfg.schRachCfg.rootSeqLen = macCellCfg->prachCfg.rootSeqLen;
292 schCellCfg.schRachCfg.rootSeqIdx = macCellCfg->prachCfg.fdm[0].rootSeqIdx;
293 schCellCfg.schRachCfg.numRootSeq = macCellCfg->prachCfg.fdm[0].numRootSeq;
294 schCellCfg.schRachCfg.k1 = macCellCfg->prachCfg.fdm[0].k1;
295 schCellCfg.schRachCfg.ssbPerRach = macCellCfg->prachCfg.ssbPerRach;
296 schCellCfg.schRachCfg.prachMultCarrBand = \
297 macCellCfg->prachCfg.prachMultCarrBand;
298 schCellCfg.schRachCfg.raContResTmr = macCellCfg->prachCfg.raContResTmr;
299 schCellCfg.schRachCfg.rsrpThreshSsb = macCellCfg->prachCfg.rsrpThreshSsb;
300 schCellCfg.schRachCfg.raRspWindow = macCellCfg->prachCfg.raRspWindow;
302 /* fill initial DL BWP */
303 schCellCfg.schInitialDlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialDlBwp.bwp.firstPrb;
304 schCellCfg.schInitialDlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialDlBwp.bwp.numPrb;
305 schCellCfg.schInitialDlBwp.bwp.scs = macCellCfg->initialDlBwp.bwp.scs;
306 schCellCfg.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->initialDlBwp.bwp.cyclicPrefix;
307 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId =
308 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId;
309 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId =
310 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.coresetId;
311 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
312 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot;
313 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.duration =
314 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.duration;
315 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
316 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol;
317 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1 =
318 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1;
319 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2 =
320 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2;
321 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4 =
322 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4;
323 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8 =
324 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8;
325 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 =
326 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16;
327 schCellCfg.schInitialDlBwp.pdschCommon.numTimeDomAlloc = macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc;
328 for(rsrcListIdx = 0; rsrcListIdx<macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc; rsrcListIdx++)
330 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0 =
331 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0;
332 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
333 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
334 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
335 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
336 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol =
337 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol;
340 /* fill initial UL BWP */
341 schCellCfg.schInitialUlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialUlBwp.bwp.firstPrb;
342 schCellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialUlBwp.bwp.numPrb;
343 schCellCfg.schInitialUlBwp.bwp.scs = macCellCfg->initialUlBwp.bwp.scs;
344 schCellCfg.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
345 schCellCfg.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc = \
346 macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc;
347 for(rsrcListIdx = 0; rsrcListIdx < macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc; rsrcListIdx++)
349 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2 =
350 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2;
351 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
352 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
353 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
354 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
355 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength =
356 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength;
359 if(macCellCfg->plmnInfoList.snssai)
361 schCellCfg.plmnInfoList.numSliceSupport = macCellCfg->plmnInfoList.numSupportedSlice;
362 MAC_ALLOC(schCellCfg.plmnInfoList.snssai, schCellCfg.plmnInfoList.numSliceSupport * sizeof(Snssai*));
363 if(!schCellCfg.plmnInfoList.snssai)
365 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
368 for(sliceIdx=0; sliceIdx<schCellCfg.plmnInfoList.numSliceSupport; sliceIdx++)
370 if(macCellCfg->plmnInfoList.snssai[sliceIdx])
372 MAC_ALLOC(schCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
373 if(!schCellCfg.plmnInfoList.snssai[sliceIdx])
375 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
378 memcpy(schCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
384 memcpy(&schCellCfg.tddCfg, &macCellCfg->tddCfg, sizeof(TDDCfg));
387 FILL_PST_MAC_TO_SCH(cfgPst, EVENT_SCH_CELL_CFG);
389 ret = (*SchCellCfgOpts[cfgPst.selector])(&cfgPst, &schCellCfg);
391 } /* end of MacSchCellCfgReq */
394 /*******************************************************************
396 * @brief Sends Cell config confirm to DU APP
400 * Function : MacSendCellCfgCfm
403 * Sends Cell config confirm to DU APP
405 * @params[in] Response status
408 * ****************************************************************/
409 void MacSendCellCfgCfm(uint16_t cellId, uint8_t response)
413 MacCellCfgCfm macCellCfgCfm;
415 memset(&pst, 0, sizeof(Pst));
417 GET_CELL_IDX(cellId, cellIdx);
418 macCellCfgCfm.cellId = macCb.macCell[cellIdx]->macCellCfg.cellId;
419 macCellCfgCfm.rsp = response;
422 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_CELL_CONFIG_CFM);
423 pst.selector = ODU_SELECTOR_LC;
425 (*packMacCellCfmOpts[pst.selector])(&pst,&macCellCfgCfm);
430 * @brief Layer Manager Configuration response handler.
434 * Function : MacProcSchCellCfgCfm
436 * This function processes cell configuration to SCH
438 * @param[in] Pst *pst
439 * @param[in] SchCellCfgCfm *schCellCfgCfm
443 uint8_t MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm *schCellCfgCfm)
445 uint16_t *cellId = NULLP;
447 #ifdef CALL_FLOW_DEBUG_LOG
448 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_SCH_CELL_CFG_CFM\n");
451 if(schCellCfgCfm->rsp == RSP_OK)
453 cellId = &schCellCfgCfm->cellId;
454 #ifdef INTEL_TIMER_MODE
455 sendToLowerMac(UL_IQ_SAMPLE, 0, (void *)cellId);
457 sendToLowerMac(CONFIG_REQUEST, 0, (void *)cellId);
462 MacSendCellCfgCfm(schCellCfgCfm->cellId, RSP_NOK);
467 /*******************************************************************
469 * @brief MAC handler for config response from PHY
473 * Function : fapiMacConfigRsp
476 * Processes config response from PHY and sends cell config
482 * ****************************************************************/
483 void fapiMacConfigRsp(uint16_t cellId)
485 /* TODO : Processing of config response from PHY */
487 /* Send cell config cfm to DU APP */
488 MacSendCellCfgCfm(cellId, RSP_OK);
491 /*******************************************************************
493 * @brief Fill and Send Cell Delete response from MAC to DU APP
497 * Function : MacSendCellDeleteRsp
499 * Functionality: Fill and Send Cell Delete response from MAC to DUAPP
501 * @params[in] MAC Cell delete result
502 * SCH Cell delete response
503 * @return ROK - success
506 * ****************************************************************/
507 uint8_t MacSendCellDeleteRsp(CellDeleteStatus result, uint8_t cellId)
509 MacCellDeleteRsp *deleteRsp=NULLP;
512 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacCellDeleteRsp));
515 DU_LOG("\nERROR --> MAC : MacSendCellDeleteRsp(): Memory allocation for Cell delete response failed");
519 /* Filling CELL delete response */
521 memset(deleteRsp, 0, sizeof(MacCellDeleteRsp));
522 deleteRsp->cellId = cellId;
523 deleteRsp->result = result;
525 /* Fill Post structure and send CELL delete response*/
526 memset(&rspPst, 0, sizeof(Pst));
527 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_CELL_DELETE_RSP);
528 return (*macDuCellDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
531 /*******************************************************************
533 * @brief Processes CELL delete response from scheduler
537 * Function : MacProcSchCellDeleteRsp
540 * Processes CELL delete from scheduler
542 * @params[in] Pst : Post structure
543 * schCellDelRsp : Scheduler CELL delete respons
544 * @return ROK - success
547 * * ****************************************************************/
548 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDelRsp)
550 uint8_t ret = ROK, sliceIdx = 0;
552 CellDeleteStatus status;
554 #ifdef CALL_FLOW_DEBUG_LOG
555 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_CELL_DELETE_RSP_TO_MAC\n");
560 if(schCellDelRsp->rsp == RSP_OK)
562 DU_LOG("\nINFO --> MAC : SCH CELL Delete response for cellId[%d] is successful ", \
563 schCellDelRsp->cellId);
564 GET_CELL_IDX(schCellDelRsp->cellId, cellIdx);
565 if(macCb.macCell[cellIdx])
567 if(macCb.macCell[cellIdx]->cellId == schCellDelRsp->cellId)
569 status = SUCCESSFUL_RSP;
570 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai)
572 for(sliceIdx = 0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++)
574 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
576 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.\
577 numSupportedSlice * sizeof(Snssai*));
579 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
580 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
581 MAC_FREE(macCb.macCell[cellIdx], sizeof(MacCellCb));
585 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
586 status = CELL_ID_INVALID;
592 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
593 status = CELL_ID_INVALID;
599 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
600 status = CELL_ID_INVALID;
603 if(MacSendCellDeleteRsp(status, schCellDelRsp->cellId) != ROK)
605 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): Failed to send CELL delete response");
612 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): schCellDelRsp is NULL");
618 /*******************************************************************
620 * @brief Sends Cell delete req to Scheduler
624 * Function : sendCellDelReqToSch
626 * Functionality: sends Cell delete req to Scheduler
628 * @params[in] SchCellDelete *schCellDel
629 * @return ROK - success
632 * ****************************************************************/
634 uint8_t sendCellDelReqToSch(SchCellDelete *schCellDel)
637 FILL_PST_MAC_TO_SCH(schPst, EVENT_CELL_DELETE_REQ_TO_SCH);
638 return(*macSchCellDeleteReqOpts[schPst.selector])(&schPst, schCellDel);
641 /*******************************************************************
643 * @brief Handles CELL Delete requst from DU APP
647 * Function : MacProcCellDeleteReq
649 * Functionality: Handles CELL Delete requst from DU APP
651 * @params[in] Pst *pst, MacCellDelete *cellDelete
652 * @return ROK - success
656 * ****************************************************************/
657 uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDelete *cellDelete)
659 uint8_t ret = ROK, cellIdx=0;
660 SchCellDelete schCellDelete;
662 DU_LOG("\nINFO --> MAC : Cell Delete Request received for cellId[%d]", cellDelete->cellId);
666 GET_CELL_IDX(cellDelete->cellId, cellIdx);
667 if(macCb.macCell[cellIdx])
669 if(macCb.macCell[cellIdx]->cellId == cellDelete->cellId)
671 memset(&schCellDelete, 0, sizeof(SchCellDelete));
672 schCellDelete.cellId = cellDelete->cellId;
673 ret = sendCellDelReqToSch(&schCellDelete);
676 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to send UE Delete Request to SCH");
682 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
689 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
696 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Sending failure response to DU");
697 if(MacSendCellDeleteRsp(CELL_ID_INVALID, cellDelete->cellId) != ROK)
699 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): failed to send cell delete rsp for cellID[%d]",\
704 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellDelete, sizeof(MacCellDelete));
708 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Received MacCellDelete is NULL");
715 * @brief free the temporary slice cfg stored in macCb.
719 * Function : freeMacSliceCfgReq
721 * free the temporary slice cfg stored in macCb
727 void freeMacSliceCfgReq(MacSliceCfgReq *cfgReq,Pst *pst)
733 if(cfgReq->numOfConfiguredSlice)
735 for(cfgIdx = 0; cfgIdx<cfgReq->numOfConfiguredSlice; cfgIdx++)
737 if(cfgReq->listOfSliceCfg[cfgIdx])
739 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio, sizeof(RrmPolicyRatio));
741 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx], sizeof(MacSliceRrmPolicy));
743 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg, cfgReq->numOfConfiguredSlice * sizeof(MacSliceRrmPolicy*));
745 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq, sizeof(MacSliceCfgReq));
749 * @brief fill Mac Slice Config Rsp
753 * Function : fillMacSliceCfgRsp
755 * This function fill Mac Slice Config Rsp
757 * @param[in] SchSliceCfgRsp *sliceCfgRsp, MacSliceCfgRsp *macSliceCfgRsp,
762 uint8_t fillMacSliceCfgRsp(SchSliceCfgRsp *schSliceCfgRsp, MacSliceCfgRsp *macSliceCfgRsp)
765 bool sliceFound = false;
768 macSliceCfgRsp->numSliceCfgRsp = schSliceCfgRsp->numSliceCfgRsp;
769 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp->listOfSliceCfgRsp, macSliceCfgRsp->numSliceCfgRsp* sizeof(MacSliceRsp*));
770 if(macSliceCfgRsp->listOfSliceCfgRsp == NULLP)
772 DU_LOG("\nERROR --> MAC : Memory allocation failedi in fillMacSliceCfgRsp");
776 for(cfgIdx = 0; cfgIdx<schSliceCfgRsp->numSliceCfgRsp; cfgIdx++)
779 if(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == RSP_OK)
784 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
785 if(macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx] == NULLP)
787 DU_LOG("\nERROR --> MAC : Memory allocation failedi in fillMacSliceCfgRsp");
791 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai = schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai;
792 if(sliceFound == true)
793 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = MAC_DU_APP_RSP_OK;
796 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = MAC_DU_APP_RSP_NOK;
797 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->cause = SLICE_NOT_PRESENT;
804 * @brief send slice cfg response to duapp.
808 * Function : MacSendSliceConfigRsp
810 * sends slice cfg response to duapp
812 * @param[in] MacSliceCfgRsp macSliceCfgRsp
816 uint8_t MacSendSliceConfigRsp(MacSliceCfgRsp *macSliceCfgRsp)
820 memset(&rspPst, 0, sizeof(Pst));
821 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_CFG_RSP);
822 return (*macDuSliceCfgRspOpts[rspPst.selector])(&rspPst, macSliceCfgRsp);
826 * @brief free the slice cfg rsp received from sch.
830 * Function : freeSchSliceCfgRsp
832 * This free the slice cfg rsp received from sch
834 * @param[in] SchSliceCfgRsp *sliceCfgrsp
838 void freeSchSliceCfgRsp(SchSliceCfgRsp *schSliceCfgRsp)
844 if(schSliceCfgRsp->numSliceCfgRsp)
846 for(cfgIdx = 0; cfgIdx< schSliceCfgRsp->numSliceCfgRsp; cfgIdx++)
848 MAC_FREE(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
850 MAC_FREE(schSliceCfgRsp->listOfSliceCfgRsp, schSliceCfgRsp->numSliceCfgRsp * sizeof(SliceRsp*));
856 * @brief Mac process the slice cfg rsp received from sch.
860 * Function : MacProcSchSliceCfgRsp
862 * This function process the slice cfg rsp received from sch
864 * @param[in] Pst *pst
865 * @param[in] SchSliceCfgRsp *sliceCfgrsp
869 uint8_t MacProcSchSliceCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceCfgRsp)
871 MacSliceCfgRsp *macSliceCfgRsp = NULLP;
875 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp, sizeof(MacSliceCfgRsp));
876 if(macSliceCfgRsp == NULLP)
878 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceCfgRsp");
881 if(schSliceCfgRsp->listOfSliceCfgRsp)
883 if(fillMacSliceCfgRsp(schSliceCfgRsp, macSliceCfgRsp) != ROK)
885 DU_LOG("\nERROR --> MAC : Failed to fill the slice cfg response");
888 MacSendSliceConfigRsp(macSliceCfgRsp);
890 freeSchSliceCfgRsp(schSliceCfgRsp);
896 * @brief send slice cfg response to duapp.
900 * Function : MacSendSliceReconfigRsp
902 * sends slice cfg response to duapp
904 * @param[in] MacSliceCfgRsp macSliceRecfgRsp
908 uint8_t MacSendSliceReconfigRsp(MacSliceCfgRsp *macSliceRecfgRsp)
912 memset(&rspPst, 0, sizeof(Pst));
913 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_RECFG_RSP);
914 return (*macDuSliceReCfgRspOpts[rspPst.selector])(&rspPst, macSliceRecfgRsp);
919 * @brief Mac process the slice cfg rsp received from sch.
923 * Function : MacProcSchSliceReCfgRsp
925 * This function process the slice cfg rsp received from sch
927 * @param[in] Pst *pst
928 * @param[in] SchSliceCfgRsp *schSliceRecfgRsp
932 uint8_t MacProcSchSliceReCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceRecfgRsp)
934 MacSliceCfgRsp *macSliceReCfgRsp = NULLP;
938 MAC_ALLOC_SHRABL_BUF(macSliceReCfgRsp, sizeof(MacSliceCfgRsp));
939 if(macSliceReCfgRsp == NULLP)
941 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceReCfgRsp");
945 if(schSliceRecfgRsp->listOfSliceCfgRsp)
947 if(fillMacSliceCfgRsp(schSliceRecfgRsp, macSliceReCfgRsp) != ROK)
949 DU_LOG("\nERROR --> MAC : Failed to fill the slice Recfg response");
952 MacSendSliceReconfigRsp(macSliceReCfgRsp);
954 freeSchSliceCfgRsp(schSliceRecfgRsp);
958 /**********************************************************************
960 **********************************************************************/