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)
97 printf("\nReceived Scheduler gen config at MAC");
98 pst->dstInst = DEFAULT_CELLS + 1;
99 SchProcGenCfgReq(pst, cfg);
105 * @brief Layer Manager Configuration response from Scheduler
109 * Function : SchSendCfgCfm
111 * This function sends general configurations response from
112 * Scheduler to DU APP.
114 * @param[in] Pst *pst, the post structure
115 * @param[in] RgMngmt *cfm, the configuration confirm structure
119 uint8_t SchSendCfgCfm(Pst *pst, RgMngmt *cfm)
121 DU_LOG("\nDEBUG --> Sending Scheduler config confirm to DU APP");
122 pst->dstEnt = ENTDUAPP;
125 pst->selector = ODU_SELECTOR_LC;
126 RgMiLrgSchCfgCfm(pst, cfm);
132 * @brief Layer Manager Configuration request handler.
136 * Function : MacProcCellCfgReq
138 * This function handles the gNB and cell configuration
139 * request received from DU APP.
140 * This API unapcks and forwards the config towards SCH
142 * @param[in] Pst *pst
143 * @param[in] MacCellCfg *macCellCfg
147 uint8_t MacProcCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
151 uint8_t ret = ROK, sliceIdx = 0;
152 MacCellCb *macCellCb;
154 memset((uint8_t *)&cfmPst, 0, sizeof(Pst));
156 MAC_ALLOC(macCellCb, sizeof(MacCellCb));
157 if(macCellCb == NULLP)
159 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of macCellCfg\n");
162 memset(macCellCb, 0, sizeof(MacCellCb));
164 GET_CELL_IDX(macCellCfg->cellId, cellIdx);
165 macCb.macCell[cellIdx] = macCellCb;
166 macCb.macCell[cellIdx]->cellId = macCellCfg->cellId;
167 memcpy(&macCb.macCell[cellIdx]->macCellCfg, macCellCfg, sizeof(MacCellCfg));
169 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
170 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
171 if(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu == NULLP)
173 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of sib1Pdu of macCellCfg\n");
176 memcpy(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, macCellCfg->sib1Cfg.sib1Pdu, \
177 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
179 macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice = macCellCfg->plmnInfoList.numSupportedSlice;
180 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice\
182 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai == NULLP)
184 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
188 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai)
190 for(sliceIdx=0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++)
192 if(macCellCfg->plmnInfoList.snssai[sliceIdx])
194 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
195 if(!macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx])
197 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
200 memcpy(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx],\
206 /* Send cell cfg to scheduler */
207 ret = MacSchCellCfgReq(pst, macCellCfg);
210 MacCellCfgCfm macCellCfgCfm;
211 macCellCfgCfm.rsp = RSP_NOK;
212 macCellCfgCfm.cellId = macCellCfg->cellId;
214 FILL_PST_MAC_TO_DUAPP(cfmPst, EVENT_MAC_CELL_CONFIG_CFM);
215 cfmPst.selector = ODU_SELECTOR_LC;
217 ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
221 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macCellCfg ,sizeof(MacCellCfg));
224 } /* end of MacProcCellCfgReq */
227 * @brief Layer Manager Configuration request handler.
231 * Function : MacSchCellCfgReq
233 * This function sends cell configuration to SCH
235 * @param[in] Pst *pst
236 * @param[in] MacCellCfg *macCellCfg
240 uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
242 SchCellCfg schCellCfg;
244 uint8_t ssbMaskIdx = 0, rsrcListIdx = 0, ret=0, sliceIdx=0;
246 memset(&cfgPst, 0, sizeof(Pst));
247 memset(&schCellCfg, 0, sizeof(SchCellCfg));
248 schCellCfg.cellId = macCellCfg->cellId;
249 schCellCfg.phyCellId = macCellCfg->phyCellId;
250 schCellCfg.numerology = macCellCfg->numerology;
251 schCellCfg.dupMode = macCellCfg->dupType;
252 schCellCfg.bandwidth = macCellCfg->dlCarrCfg.bw;
253 schCellCfg.dlFreq = macCellCfg->dlCarrCfg.freq;
254 schCellCfg.ulFreq = macCellCfg->ulCarrCfg.freq;
256 /* fill ssb scheduler parameters */
257 schCellCfg.ssbSchCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
258 schCellCfg.ssbSchCfg.scsCommon = macCellCfg->ssbCfg.scsCmn;
259 schCellCfg.ssbSchCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
260 schCellCfg.ssbSchCfg.ssbPeriod = ssbPeriodicity[macCellCfg->ssbCfg.ssbPeriod];
261 schCellCfg.ssbSchCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
262 for(ssbMaskIdx=0; ssbMaskIdx<SSB_MASK_SIZE; ssbMaskIdx++)
264 schCellCfg.ssbSchCfg.nSSBMask[ssbMaskIdx] = macCellCfg->ssbCfg.ssbMask[ssbMaskIdx];
266 schCellCfg.ssbSchCfg.totNumSsb = countSetBits(schCellCfg.ssbSchCfg.nSSBMask[0]);
268 /* fill SIB1 scheduler parameters */
269 schCellCfg.sib1SchCfg.sib1PduLen = macCellCfg->sib1Cfg.sib1PduLen;
270 schCellCfg.sib1SchCfg.sib1RepetitionPeriod = macCellCfg->sib1Cfg.sib1RepetitionPeriod;
271 schCellCfg.sib1SchCfg.coresetZeroIndex = macCellCfg->sib1Cfg.coresetZeroIndex;
272 schCellCfg.sib1SchCfg.searchSpaceZeroIndex = macCellCfg->sib1Cfg.searchSpaceZeroIndex;
273 schCellCfg.sib1SchCfg.sib1Mcs = macCellCfg->sib1Cfg.sib1Mcs;
274 schCellCfg.sib1SchCfg.pageCfg.numPO = macCellCfg->sib1Cfg.pagingCfg.numPO;
275 schCellCfg.sib1SchCfg.pageCfg.poPresent = macCellCfg->sib1Cfg.pagingCfg.poPresent;
277 if(schCellCfg.sib1SchCfg.pageCfg.poPresent)
279 memcpy(schCellCfg.sib1SchCfg.pageCfg.pagingOcc, macCellCfg->sib1Cfg.pagingCfg.pagingOcc, MAX_PO_PER_PF);
282 /* fill RACH config params */
283 schCellCfg.schRachCfg.prachCfgIdx = macCellCfg->prachCfg.prachCfgIdx;
284 schCellCfg.schRachCfg.prachSubcSpacing = \
285 macCellCfg->prachCfg.prachSubcSpacing;
286 schCellCfg.schRachCfg.msg1FreqStart = macCellCfg->prachCfg.msg1FreqStart;
287 schCellCfg.schRachCfg.msg1Fdm = macCellCfg->prachCfg.msg1Fdm;
288 schCellCfg.schRachCfg.rootSeqLen = macCellCfg->prachCfg.rootSeqLen;
289 schCellCfg.schRachCfg.rootSeqIdx = macCellCfg->prachCfg.fdm[0].rootSeqIdx;
290 schCellCfg.schRachCfg.numRootSeq = macCellCfg->prachCfg.fdm[0].numRootSeq;
291 schCellCfg.schRachCfg.k1 = macCellCfg->prachCfg.fdm[0].k1;
292 schCellCfg.schRachCfg.ssbPerRach = macCellCfg->prachCfg.ssbPerRach;
293 schCellCfg.schRachCfg.prachMultCarrBand = \
294 macCellCfg->prachCfg.prachMultCarrBand;
295 schCellCfg.schRachCfg.raContResTmr = macCellCfg->prachCfg.raContResTmr;
296 schCellCfg.schRachCfg.rsrpThreshSsb = macCellCfg->prachCfg.rsrpThreshSsb;
297 schCellCfg.schRachCfg.raRspWindow = macCellCfg->prachCfg.raRspWindow;
299 /* fill initial DL BWP */
300 schCellCfg.schInitialDlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialDlBwp.bwp.firstPrb;
301 schCellCfg.schInitialDlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialDlBwp.bwp.numPrb;
302 schCellCfg.schInitialDlBwp.bwp.scs = macCellCfg->initialDlBwp.bwp.scs;
303 schCellCfg.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->initialDlBwp.bwp.cyclicPrefix;
304 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId =
305 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId;
306 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId =
307 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.coresetId;
308 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
309 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot;
310 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.duration =
311 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.duration;
312 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
313 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol;
314 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1 =
315 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1;
316 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2 =
317 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2;
318 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4 =
319 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4;
320 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8 =
321 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8;
322 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 =
323 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16;
324 schCellCfg.schInitialDlBwp.pdschCommon.numTimeDomAlloc = macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc;
325 for(rsrcListIdx = 0; rsrcListIdx<macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc; rsrcListIdx++)
327 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0 =
328 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0;
329 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
330 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
331 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
332 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
333 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol =
334 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol;
337 /* fill initial UL BWP */
338 schCellCfg.schInitialUlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialUlBwp.bwp.firstPrb;
339 schCellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialUlBwp.bwp.numPrb;
340 schCellCfg.schInitialUlBwp.bwp.scs = macCellCfg->initialUlBwp.bwp.scs;
341 schCellCfg.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
342 schCellCfg.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc = \
343 macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc;
344 for(rsrcListIdx = 0; rsrcListIdx < macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc; rsrcListIdx++)
346 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2 =
347 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2;
348 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
349 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
350 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
351 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
352 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength =
353 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength;
356 if(macCellCfg->plmnInfoList.snssai)
358 schCellCfg.plmnInfoList.numSliceSupport = macCellCfg->plmnInfoList.numSupportedSlice;
359 MAC_ALLOC(schCellCfg.plmnInfoList.snssai, schCellCfg.plmnInfoList.numSliceSupport * sizeof(Snssai*));
360 if(!schCellCfg.plmnInfoList.snssai)
362 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
365 for(sliceIdx=0; sliceIdx<schCellCfg.plmnInfoList.numSliceSupport; sliceIdx++)
367 if(macCellCfg->plmnInfoList.snssai[sliceIdx])
369 MAC_ALLOC(schCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
370 if(!schCellCfg.plmnInfoList.snssai[sliceIdx])
372 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
375 memcpy(schCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
381 memcpy(&schCellCfg.tddCfg, &macCellCfg->tddCfg, sizeof(TDDCfg));
384 FILL_PST_MAC_TO_SCH(cfgPst, EVENT_SCH_CELL_CFG);
386 ret = (*SchCellCfgOpts[cfgPst.selector])(&cfgPst, &schCellCfg);
388 } /* end of MacSchCellCfgReq */
391 /*******************************************************************
393 * @brief Sends Cell config confirm to DU APP
397 * Function : MacSendCellCfgCfm
400 * Sends Cell config confirm to DU APP
402 * @params[in] Response status
405 * ****************************************************************/
406 void MacSendCellCfgCfm(uint16_t cellId, uint8_t response)
410 MacCellCfgCfm macCellCfgCfm;
412 memset(&pst, 0, sizeof(Pst));
414 GET_CELL_IDX(cellId, cellIdx);
415 macCellCfgCfm.cellId = macCb.macCell[cellIdx]->macCellCfg.cellId;
416 macCellCfgCfm.rsp = response;
419 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_CELL_CONFIG_CFM);
420 pst.selector = ODU_SELECTOR_LC;
422 (*packMacCellCfmOpts[pst.selector])(&pst,&macCellCfgCfm);
427 * @brief Layer Manager Configuration response handler.
431 * Function : MacProcSchCellCfgCfm
433 * This function processes cell configuration to SCH
435 * @param[in] Pst *pst
436 * @param[in] SchCellCfgCfm *schCellCfgCfm
440 uint8_t MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm *schCellCfgCfm)
442 uint16_t *cellId = NULLP;
444 #ifdef CALL_FLOW_DEBUG_LOG
445 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_SCH_CELL_CFG_CFM\n");
448 if(schCellCfgCfm->rsp == RSP_OK)
450 cellId = &schCellCfgCfm->cellId;
451 #ifdef INTEL_TIMER_MODE
452 sendToLowerMac(UL_IQ_SAMPLE, 0, (void *)cellId);
454 sendToLowerMac(CONFIG_REQUEST, 0, (void *)cellId);
459 MacSendCellCfgCfm(schCellCfgCfm->cellId, RSP_NOK);
464 /*******************************************************************
466 * @brief MAC handler for config response from PHY
470 * Function : fapiMacConfigRsp
473 * Processes config response from PHY and sends cell config
479 * ****************************************************************/
480 void fapiMacConfigRsp(uint16_t cellId)
482 /* TODO : Processing of config response from PHY */
484 /* Send cell config cfm to DU APP */
485 MacSendCellCfgCfm(cellId, RSP_OK);
488 /*******************************************************************
490 * @brief Fill and Send Cell Delete response from MAC to DU APP
494 * Function : MacSendCellDeleteRsp
496 * Functionality: Fill and Send Cell Delete response from MAC to DUAPP
498 * @params[in] MAC Cell delete result
499 * SCH Cell delete response
500 * @return ROK - success
503 * ****************************************************************/
504 uint8_t MacSendCellDeleteRsp(CellDeleteStatus result, uint8_t cellId)
506 MacCellDeleteRsp *deleteRsp=NULLP;
509 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacCellDeleteRsp));
512 DU_LOG("\nERROR --> MAC : MacSendCellDeleteRsp(): Memory allocation for Cell delete response failed");
516 /* Filling CELL delete response */
518 memset(deleteRsp, 0, sizeof(MacCellDeleteRsp));
519 deleteRsp->cellId = cellId;
520 deleteRsp->result = result;
522 /* Fill Post structure and send CELL delete response*/
523 memset(&rspPst, 0, sizeof(Pst));
524 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_CELL_DELETE_RSP);
525 return (*macDuCellDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
528 /*******************************************************************
530 * @brief Processes CELL delete response from scheduler
534 * Function : MacProcSchCellDeleteRsp
537 * Processes CELL delete from scheduler
539 * @params[in] Pst : Post structure
540 * schCellDelRsp : Scheduler CELL delete respons
541 * @return ROK - success
544 * * ****************************************************************/
545 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDelRsp)
547 uint8_t ret = ROK, sliceIdx = 0;
549 CellDeleteStatus status;
551 #ifdef CALL_FLOW_DEBUG_LOG
552 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_CELL_DELETE_RSP_TO_MAC\n");
557 if(schCellDelRsp->rsp == RSP_OK)
559 DU_LOG("\nINFO --> MAC : SCH CELL Delete response for cellId[%d] is successful ", \
560 schCellDelRsp->cellId);
561 GET_CELL_IDX(schCellDelRsp->cellId, cellIdx);
562 if(macCb.macCell[cellIdx])
564 if(macCb.macCell[cellIdx]->cellId == schCellDelRsp->cellId)
566 status = SUCCESSFUL_RSP;
567 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai)
569 for(sliceIdx = 0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++)
571 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
573 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.\
574 numSupportedSlice * sizeof(Snssai*));
576 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
577 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
578 MAC_FREE(macCb.macCell[cellIdx], sizeof(MacCellCb));
582 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
583 status = CELL_ID_INVALID;
589 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
590 status = CELL_ID_INVALID;
596 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
597 status = CELL_ID_INVALID;
600 if(MacSendCellDeleteRsp(status, schCellDelRsp->cellId) != ROK)
602 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): Failed to send CELL delete response");
609 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): schCellDelRsp is NULL");
615 /*******************************************************************
617 * @brief Sends Cell delete req to Scheduler
621 * Function : sendCellDelReqToSch
623 * Functionality: sends Cell delete req to Scheduler
625 * @params[in] SchCellDelete *schCellDel
626 * @return ROK - success
629 * ****************************************************************/
631 uint8_t sendCellDelReqToSch(SchCellDelete *schCellDel)
634 FILL_PST_MAC_TO_SCH(schPst, EVENT_CELL_DELETE_REQ_TO_SCH);
635 return(*macSchCellDeleteReqOpts[schPst.selector])(&schPst, schCellDel);
638 /*******************************************************************
640 * @brief Handles CELL Delete requst from DU APP
644 * Function : MacProcCellDeleteReq
646 * Functionality: Handles CELL Delete requst from DU APP
648 * @params[in] Pst *pst, MacCellDelete *cellDelete
649 * @return ROK - success
653 * ****************************************************************/
654 uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDelete *cellDelete)
656 uint8_t ret = ROK, cellIdx=0;
657 SchCellDelete schCellDelete;
659 DU_LOG("\nINFO --> MAC : Cell Delete Request received for cellId[%d]", cellDelete->cellId);
663 GET_CELL_IDX(cellDelete->cellId, cellIdx);
664 if(macCb.macCell[cellIdx])
666 if(macCb.macCell[cellIdx]->cellId == cellDelete->cellId)
668 memset(&schCellDelete, 0, sizeof(SchCellDelete));
669 schCellDelete.cellId = cellDelete->cellId;
670 ret = sendCellDelReqToSch(&schCellDelete);
673 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to send UE Delete Request to SCH");
679 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
686 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
693 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Sending failure response to DU");
694 if(MacSendCellDeleteRsp(CELL_ID_INVALID, cellDelete->cellId) != ROK)
696 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): failed to send cell delete rsp for cellID[%d]",\
701 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellDelete, sizeof(MacCellDelete));
705 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Received MacCellDelete is NULL");
712 * @brief free the temporary slice cfg stored in macCb.
716 * Function : freeMacSliceCfgReq
718 * free the temporary slice cfg stored in macCb
724 void freeMacSliceCfgReq(MacSliceCfgReq *cfgReq,Pst *pst)
730 if(cfgReq->numOfConfiguredSlice)
732 for(cfgIdx = 0; cfgIdx<cfgReq->numOfConfiguredSlice; cfgIdx++)
734 if(cfgReq->listOfSliceCfg[cfgIdx])
736 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio, sizeof(RrmPolicyRatio));
738 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx], sizeof(MacSliceRrmPolicy));
740 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg, cfgReq->numOfConfiguredSlice * sizeof(MacSliceRrmPolicy*));
742 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq, sizeof(MacSliceCfgReq));
746 * @brief fill Mac Slice Config Rsp
750 * Function : fillMacSliceCfgRsp
752 * This function fill Mac Slice Config Rsp
754 * @param[in] SchSliceCfgRsp *sliceCfgRsp, MacSliceCfgRsp *macSliceCfgRsp,
759 uint8_t fillMacSliceCfgRsp(SchSliceCfgRsp *schSliceCfgRsp, MacSliceCfgRsp *macSliceCfgRsp)
762 bool sliceFound = false;
765 macSliceCfgRsp->numSliceCfgRsp = schSliceCfgRsp->numSliceCfgRsp;
766 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp->listOfSliceCfgRsp, macSliceCfgRsp->numSliceCfgRsp* sizeof(MacSliceRsp*));
767 if(macSliceCfgRsp->listOfSliceCfgRsp == NULLP)
769 DU_LOG("\nERROR --> MAC : Memory allocation failedi in fillMacSliceCfgRsp");
773 for(cfgIdx = 0; cfgIdx<schSliceCfgRsp->numSliceCfgRsp; cfgIdx++)
776 if(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == RSP_OK)
781 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
782 if(macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx] == NULLP)
784 DU_LOG("\nERROR --> MAC : Memory allocation failedi in fillMacSliceCfgRsp");
788 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai = schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai;
789 if(sliceFound == true)
790 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = MAC_DU_APP_RSP_OK;
793 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = MAC_DU_APP_RSP_NOK;
794 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->cause = SLICE_NOT_PRESENT;
801 * @brief send slice cfg response to duapp.
805 * Function : MacSendSliceConfigRsp
807 * sends slice cfg response to duapp
809 * @param[in] MacSliceCfgRsp macSliceCfgRsp
813 uint8_t MacSendSliceConfigRsp(MacSliceCfgRsp *macSliceCfgRsp)
817 memset(&rspPst, 0, sizeof(Pst));
818 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_CFG_RSP);
819 return (*macDuSliceCfgRspOpts[rspPst.selector])(&rspPst, macSliceCfgRsp);
823 * @brief free the slice cfg rsp received from sch.
827 * Function : freeSchSliceCfgRsp
829 * This free the slice cfg rsp received from sch
831 * @param[in] SchSliceCfgRsp *sliceCfgrsp
835 void freeSchSliceCfgRsp(SchSliceCfgRsp *schSliceCfgRsp)
841 if(schSliceCfgRsp->numSliceCfgRsp)
843 for(cfgIdx = 0; cfgIdx< schSliceCfgRsp->numSliceCfgRsp; cfgIdx++)
845 MAC_FREE(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
847 MAC_FREE(schSliceCfgRsp->listOfSliceCfgRsp, schSliceCfgRsp->numSliceCfgRsp * sizeof(SliceRsp*));
853 * @brief Mac process the slice cfg rsp received from sch.
857 * Function : MacProcSchSliceCfgRsp
859 * This function process the slice cfg rsp received from sch
861 * @param[in] Pst *pst
862 * @param[in] SchSliceCfgRsp *sliceCfgrsp
866 uint8_t MacProcSchSliceCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceCfgRsp)
868 MacSliceCfgRsp *macSliceCfgRsp = NULLP;
872 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp, sizeof(MacSliceCfgRsp));
873 if(macSliceCfgRsp == NULLP)
875 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceCfgRsp");
878 if(schSliceCfgRsp->listOfSliceCfgRsp)
880 if(fillMacSliceCfgRsp(schSliceCfgRsp, macSliceCfgRsp) != ROK)
882 DU_LOG("\nERROR --> MAC : Failed to fill the slice cfg response");
885 MacSendSliceConfigRsp(macSliceCfgRsp);
887 freeSchSliceCfgRsp(schSliceCfgRsp);
893 * @brief send slice cfg response to duapp.
897 * Function : MacSendSliceReconfigRsp
899 * sends slice cfg response to duapp
901 * @param[in] MacSliceCfgRsp macSliceRecfgRsp
905 uint8_t MacSendSliceReconfigRsp(MacSliceCfgRsp *macSliceRecfgRsp)
909 memset(&rspPst, 0, sizeof(Pst));
910 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_RECFG_RSP);
911 return (*macDuSliceReCfgRspOpts[rspPst.selector])(&rspPst, macSliceRecfgRsp);
916 * @brief Mac process the slice cfg rsp received from sch.
920 * Function : MacProcSchSliceReCfgRsp
922 * This function process the slice cfg rsp received from sch
924 * @param[in] Pst *pst
925 * @param[in] SchSliceCfgRsp *schSliceRecfgRsp
929 uint8_t MacProcSchSliceReCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceRecfgRsp)
931 MacSliceCfgRsp *macSliceReCfgRsp = NULLP;
935 MAC_ALLOC_SHRABL_BUF(macSliceReCfgRsp, sizeof(MacSliceCfgRsp));
936 if(macSliceReCfgRsp == NULLP)
938 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceReCfgRsp");
942 if(schSliceRecfgRsp->listOfSliceCfgRsp)
944 if(fillMacSliceCfgRsp(schSliceRecfgRsp, macSliceReCfgRsp) != ROK)
946 DU_LOG("\nERROR --> MAC : Failed to fill the slice Recfg response");
949 MacSendSliceReconfigRsp(macSliceReCfgRsp);
951 freeSchSliceCfgRsp(schSliceRecfgRsp);
955 /**********************************************************************
957 **********************************************************************/