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 /************************************************************************
25 Desc: C source code for Layer Manager Interface Module
29 **********************************************************************/
31 /** @file rg_sch_lmm.c
32 @brief This file contains the Layer Management interface module implementation for scheduler.
33 The functions for the configuration, control, status and statistics
34 request primitives are defined here.
38 /* header include files (.h) */
39 #include "common_def.h"
40 #include "rg_env.h" /* MAC Environment Defines */
41 #include "rgr.h" /* RGR Interface defines */
42 #include "tfu.h" /* RGU Interface defines */
43 #include "lrg.h" /* LRG Interface defines */
44 #include "rgm.h" /* RGM Interface defines */
45 #include "rg_sch.h" /* Scheduler defines */
46 #include "rg_sch_inf.h" /* Scheduler defines */
47 #include "rg_sch_err.h" /* MAC error defines */
49 #include "rg_sch_cmn.h" /* typedefs for Scheduler */
51 #include "rl_interface.h"
52 #include "rl_common.h"
54 /* header/extern include files (.x) */
55 #include "rgr.x" /* RGR Interface includes */
56 #include "rgm.x" /* RGM Interface includes */
57 #include "tfu.x" /* RGU Interface includes */
58 #include "lrg.x" /* LRG Interface includes */
59 #include "rg_sch_inf.x" /* Scheduler defines */
60 #include "rg_sch.x" /* Scheduler includes */
62 #include "rg_sch_cmn.x" /* typedefs for Scheduler */
65 Void rgSCHCmnInit ARGS((Void));
67 /* forward references */
68 extern int schActvInit(Ent entity, Inst instId, Region region, Reason reason);
70 static uint16_t rgSCHLmmSapCfg ARGS((
77 static Void rgSCHLmmShutdown ARGS((
82 void printSchCellInfo(void)
86 for (idx = 0; idx < rgSchCb[inst].numSaps; idx++)
88 /* Unbind all the TFU SAP */
89 /* Free the memory held by the cell associated
91 if (rgSchCb[inst].tfuSap[idx].cell != NULLP)
93 DU_LOG("\nINFO --> SCH : CELL %d\n", idx);
94 DU_LOG("\nINFO --> SCH : NUM UEs :%d\n",rgSchCb[inst].tfuSap[idx].cell->ueLst.nmbEnt);
100 * @brief SAP Configuration Handler.
104 * Function : rgSCHLmmSapCfg
106 * This function in called by SchProcGenCfgReq(). It handles the
107 * interface SAP configuration of the scheduler instance. It
108 * initializes the sapState to LRG_UNBND. Returns
109 * reason for success/failure of this function.
111 * @param[in] RgCfg *cfg, the Configuaration information
113 * -# LCM_REASON_GENCFG_NOT_DONE
114 * -# LCM_REASON_INVALID_SAP
115 * -# LCM_REASON_NOT_APPL
118 static uint16_t rgSCHLmmSapCfg
121 RgCfg *cfg, /* Configuaration information */
122 uint8_t sapIdx, /* SAP index */
123 Elmnt sapType /* SAP Type */
126 uint16_t ret = LCM_REASON_NOT_APPL;
127 RgSchLowSapCfgInfo *lowSapCfg = NULLP;
128 RgSchUpSapCfgInfo *upSapCfg = NULLP;
129 Inst inst = (dInst - SCH_INST_START);
131 /* Check if Gen Config has been done */
137 if ((cfg->s.schInstCfg.rgrSap[sapIdx].selector != ODU_SELECTOR_TC) &&
138 (cfg->s.schInstCfg.rgrSap[sapIdx].selector != ODU_SELECTOR_LC))
140 ret = LCM_REASON_INVALID_PAR_VAL;
141 DU_LOG("\nERROR --> SCH : rgSCHLmmSapCfg(): unsupported"
142 " Selector value for RGR.");
146 if(rgSchCb[inst].rgrSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
148 rgSchCb[inst].rgrSap[sapIdx].sapSta.sapState = LRG_UNBND;
150 upSapCfg = &rgSchCb[inst].rgrSap[sapIdx].sapCfg;
152 upSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.rgrSap[sapIdx].ent;
153 upSapCfg->sapPst.dstInst = cfg->s.schInstCfg.rgrSap[sapIdx].inst;
154 upSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.rgrSap[sapIdx].procId;
155 upSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
156 upSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
158 upSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
159 upSapCfg->sapPst.region = cfg->s.schInstCfg.rgrSap[sapIdx].mem.region;
160 upSapCfg->sapPst.pool = cfg->s.schInstCfg.rgrSap[sapIdx].mem.pool;
161 upSapCfg->sapPst.selector = cfg->s.schInstCfg.rgrSap[sapIdx].selector;
162 upSapCfg->sapPst.route = cfg->s.schInstCfg.rgrSap[sapIdx].route;
163 upSapCfg->sapPst.intfVer = 0;
164 upSapCfg->sapPst.event = 0;
165 upSapCfg->sapPst.prior = cfg->s.schInstCfg.rgrSap[sapIdx].prior;
166 upSapCfg->suId = cfg->s.schInstCfg.rgrSap[sapIdx].suId;
167 upSapCfg->spId = cfg->s.schInstCfg.rgrSap[sapIdx].spId;
171 if ((cfg->s.schInstCfg.tfuSap[sapIdx].selector != ODU_SELECTOR_TC) &&
172 (cfg->s.schInstCfg.tfuSap[sapIdx].selector != ODU_SELECTOR_LC))
174 ret = LCM_REASON_INVALID_PAR_VAL;
175 DU_LOG("\nERROR --> SCH : rgSCHLmmSapCfg(): unsupported"
176 " Selector value for TFU.");
180 if (rgSchCb[inst].tfuSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
182 rgSchCb[inst].tfuSap[sapIdx].sapSta.sapState = LRG_UNBND;
184 /* Initialize the sap timer */
185 cmInitTimers(&(rgSchCb[inst].tfuSap[sapIdx].tmrBlk), 1);
186 lowSapCfg = &rgSchCb[inst].tfuSap[sapIdx].sapCfg;
188 lowSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.tfuSap[sapIdx].ent;
189 lowSapCfg->sapPst.dstInst = cfg->s.schInstCfg.tfuSap[sapIdx].inst;
190 lowSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.tfuSap[sapIdx].procId;
191 lowSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
192 lowSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
194 lowSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
195 lowSapCfg->sapPst.region = cfg->s.schInstCfg.tfuSap[sapIdx].mem.region;
196 lowSapCfg->sapPst.pool = cfg->s.schInstCfg.tfuSap[sapIdx].mem.pool;
197 lowSapCfg->sapPst.selector = cfg->s.schInstCfg.tfuSap[sapIdx].selector;
198 lowSapCfg->sapPst.route = cfg->s.schInstCfg.tfuSap[sapIdx].route;
199 lowSapCfg->sapPst.intfVer = 0;
200 lowSapCfg->sapPst.event = 0;
201 lowSapCfg->sapPst.prior = cfg->s.schInstCfg.tfuSap[sapIdx].prior;
202 lowSapCfg->suId = cfg->s.schInstCfg.tfuSap[sapIdx].suId;
203 lowSapCfg->spId = cfg->s.schInstCfg.tfuSap[sapIdx].spId;
204 memcpy(&lowSapCfg->bndTmr,
205 &cfg->s.schInstCfg.tfuSap[sapIdx].bndTmr,
210 if ((cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_LWLC) &&
211 (cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_LC) &&
212 (cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_TC))
214 ret = LCM_REASON_INVALID_PAR_VAL;
215 DU_LOG("\nERROR --> SCH : rgSCHLmmSapCfg(): unsupported"
216 " Selector value for RGM.");
220 if (rgSchCb[inst].rgmSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
222 rgSchCb[inst].rgmSap[sapIdx].sapSta.sapState = LRG_UNBND;
224 upSapCfg = &rgSchCb[inst].rgmSap[sapIdx].sapCfg;
225 upSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.rgmSap[sapIdx].ent;
226 upSapCfg->sapPst.dstInst = cfg->s.schInstCfg.rgmSap[sapIdx].inst;
227 upSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.rgmSap[sapIdx].procId;
228 upSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
229 upSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
231 upSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
232 upSapCfg->sapPst.region = cfg->s.schInstCfg.rgmSap[sapIdx].mem.region;
233 upSapCfg->sapPst.pool = cfg->s.schInstCfg.rgmSap[sapIdx].mem.pool;
234 upSapCfg->sapPst.selector = cfg->s.schInstCfg.rgmSap[sapIdx].selector;
235 upSapCfg->sapPst.route = cfg->s.schInstCfg.rgmSap[sapIdx].route;
236 upSapCfg->sapPst.intfVer = 0;
237 upSapCfg->sapPst.event = 0;
238 upSapCfg->sapPst.prior = cfg->s.schInstCfg.rgmSap[sapIdx].prior;
239 upSapCfg->suId = cfg->s.schInstCfg.rgmSap[sapIdx].suId;
240 upSapCfg->spId = cfg->s.schInstCfg.rgmSap[sapIdx].spId;
244 /* would never reach here */
251 /***********************************************************
253 * Func : rgSCHLmmShutdown
256 * Desc : Handles the scheduler instance shutdown request. Calls
257 * rgSCHCfgFreeCellCb(RgSchCellCb*) to handle each cellCb deallocation.
264 * File : rg_sch_lmm.c
266 **********************************************************/
267 static Void rgSCHLmmShutdown(Inst inst)
269 Inst dInst = inst + SCH_INST_START;
272 CmLList *lnk = NULLP;
273 RgSchCb *instCb = &rgSchCb[inst];
274 RgSchCellCb *cell = NULLP;
275 RgSchL2MeasCb *measCb;
277 RgSchCmnUlCell *cellUl;
278 RgSchClcBoRpt *bo = NULL;
282 for (idx = 0; idx < instCb->numSaps; idx++)
284 /* got the cell break the loop */
285 cell = instCb->rgrSap[idx].cell;
288 /* Free the memory held up by ulAllocInfo */
289 cellUl = RG_SCH_CMN_GET_UL_CELL(cell);
291 for(ulAllocIdx = 0; ulAllocIdx < RGSCH_SF_ALLOC_SIZE; ulAllocIdx++)
293 for(ulAllocIdx = 0; ulAllocIdx < RGSCH_NUM_SUB_FRAMES; ulAllocIdx++)
296 if(cell->sfAllocArr[ulAllocIdx].ulUeInfo.ulAllocInfo != NULLP)
298 /* ccpu00117052 - MOD - Passing double pointer
299 for proper NULLP assignment*/
300 rgSCHUtlFreeSBuf(cell->instIdx,
301 (Data **)(&(cell->sfAllocArr[ulAllocIdx].ulUeInfo.\
303 cellUl->maxAllocPerUlSf * sizeof(RgInfUeUlAlloc));
306 /* Free the memory allocated to measCb */
307 lnk = cell->l2mList.first;
310 measCb = (RgSchL2MeasCb *)lnk->node;
311 cmLListDelFrm(&cell->l2mList, lnk);
313 /* ccpu00117052 - MOD - Passing double pointer
314 for proper NULLP assignment*/
315 rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&measCb,\
316 sizeof(RgSchL2MeasCb));
319 /* Free mem if any present for boLst for common channels */
320 for(idx = 0; idx < RGSCH_MAX_CMN_LC_CB; idx++)
322 lnk = (CmLList *)cell->cmnLcCb[idx].boLst.first;
325 bo = (RgSchClcBoRpt *)(lnk->node);
327 cmLListDelFrm(&cell->cmnLcCb[idx].boLst, &bo->boLstEnt);
328 rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&bo, sizeof(RgSchClcBoRpt));
336 rgSCHLaaDeInitEnbCb(&rgSchCb[inst]);
338 for (idx = 0; idx < rgSchCb[inst].numSaps; idx++)
340 /* Unbind all the TFU SAP */
341 if(rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_WAIT_BNDCFM)
343 //rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg, LRG_UNBND);
344 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
346 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[idx]);
348 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
350 if(rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND)
352 //rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg, LRG_UNBND);
353 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
355 /* Free the memory held by the cell associated with this SAP */
356 if (rgSchCb[inst].tfuSap[idx].cell != NULLP)
357 rgSCHCfgFreeCellCb(rgSchCb[inst].tfuSap[idx].cell);
358 rgSchCb[inst].tfuSap[idx].cell = NULLP;
360 /* Free the memory held by the scheduler instance */
361 /* Deallocate RGR saps */
362 SPutSBuf(rgSchCb[inst].rgSchInit.region,
363 rgSchCb[inst].rgSchInit.pool,
364 (Data *)rgSchCb[inst].rgrSap,
365 (sizeof(RgSchUpSapCb) * rgSchCb[inst].numSaps));
366 rgSchCb[inst].rgrSap = NULLP;
367 /* Deallocate RGM saps */
368 SPutSBuf(rgSchCb[inst].rgSchInit.region,
369 rgSchCb[inst].rgSchInit.pool,
370 (Data *)rgSchCb[inst].rgmSap,
371 (sizeof(RgSchUpSapCb) * rgSchCb[inst].numSaps));
372 rgSchCb[inst].rgmSap = NULLP;
374 /* Deallocate TFU saps */
375 SPutSBuf(rgSchCb[inst].rgSchInit.region,
376 rgSchCb[inst].rgSchInit.pool,
377 (Data *)rgSchCb[inst].tfuSap,
378 (sizeof(RgSchLowSapCb) * rgSchCb[inst].numSaps));
379 rgSchCb[inst].tfuSap = NULLP;
381 /* Deallocate bndCfmResponses */
382 SPutSBuf(rgSchCb[inst].rgSchInit.region,
383 rgSchCb[inst].rgSchInit.pool,
384 (Data *)rgSchCb[inst].genCfg.bndCfmResp,
385 (sizeof(RgSchLmResponse) * rgSchCb[inst].numSaps));
386 rgSchCb[inst].genCfg.bndCfmResp = NULLP;
387 /* De-register the Timer Service */
388 (Void) SDeregTmrMt(rgSchCb[inst].rgSchInit.ent, dInst,
389 (S16)rgSchCb[inst].genCfg.tmrRes, schActvTmr);
391 /* call back the task initialization function to intialize
392 * the global rgSchCb[inst] Struct */
393 schActvInit(rgSchCb[inst].rgSchInit.ent, dInst, rgSchCb[inst].rgSchInit.region,
394 rgSchCb[inst].rgSchInit.reason);
396 /* Set Config done in TskInit */
397 rgSchCb[inst].rgSchInit.cfgDone = FALSE;
403 /***********************************************************
405 * Func : rgSCHLmmGenCntrl
408 * Desc : Processes the LM control request for STGEN elmnt.
415 * File : rg_sch_lmm.c
417 **********************************************************/
418 Void rgSCHLmmGenCntrl(RgMngmt *cntrl,RgMngmt *cfm,Pst *cfmPst)
420 Inst inst = (cfmPst->srcInst - SCH_INST_START); /* Scheduler instance ID */
422 cfm->cfm.status = LCM_PRIM_OK;
423 cfm->cfm.reason = LCM_REASON_NOT_APPL;
426 switch(cntrl->t.cntrl.action)
429 /* Action is Enable */
430 switch(cntrl->t.cntrl.subAction)
433 /* Enable Unsolicited Status (alarms) */
434 rgSchCb[inst].rgSchInit.usta = TRUE;
435 /*Store the response and TransId for sending the Alarms */
436 memcpy(&rgSchCb[inst].genCfg.ustaResp.response,
437 &cntrl->hdr.response, sizeof(Resp));
438 rgSchCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
441 /* Enable Debug Printing */
443 rgSchCb[inst].rgSchInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
446 #ifdef PHY_ERROR_LOGING
449 rgSchUlAllocCntr.mcs = cntrl->t.cntrl.s.rgSchUlAllocCntrl.mcs;
450 rgSchUlAllocCntr.numOfRb = cntrl->t.cntrl.s.rgSchUlAllocCntrl.numOfRb;
451 rgSchUlAllocCntr.rbStart = cntrl->t.cntrl.s.rgSchUlAllocCntrl.rbStart;
452 rgSchUlAllocCntr.testStart = cntrl->t.cntrl.s.rgSchUlAllocCntrl.testStart;
453 rgSchUlAllocCntr.enaLog = cntrl->t.cntrl.s.rgSchUlAllocCntrl.enaLog;
454 rgSchUlAllocCntr.logTime = cntrl->t.cntrl.s.rgSchUlAllocCntrl.logTime;
455 rgSchUlAllocCntr.crcOk = 0;
456 rgSchUlAllocCntr.crcErr = 0;
457 rgSchUlAllocCntr.numUlPackets = 0;
458 rgSchUlAllocCntr.numPrach = 0;
459 rgSchUlAllocCntr.taZero = 0;
465 memset(&hqRetxStats, 0, sizeof(RgSchHqRetxStats));
466 memset(&hqFailStats, 0, sizeof(RgSchNackAckStats));
472 cfm->cfm.status = LCM_PRIM_NOK;
473 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
474 DU_LOG("\nERROR --> SCH : rgSCHLmmGenCntrl(): "
475 "invalid subaction=%d", cntrl->t.cntrl.subAction);
480 /* Action is Diable immidiately */
481 switch(cntrl->t.cntrl.subAction)
484 /* Disable Unsolicited Status (alarms) */
485 rgSchCb[inst].rgSchInit.usta = FALSE;
488 /* Disable Debug Printing */
490 rgSchCb[inst].rgSchInit.dbgMask &=\
491 ~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
496 cfm->cfm.status = LCM_PRIM_NOK;
497 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
498 DU_LOG("\nERROR --> SCH : rgSCHLmmGenCntrl():"
499 " invalid subaction=%d", cntrl->t.cntrl.subAction);
504 /* Free all the memory dynamically allocated by MAC */
505 rgSCHLmmShutdown(inst);
508 cfm->cfm.status = LCM_PRIM_NOK;
509 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
510 DU_LOG("\nERROR --> SCH : rgSCHLmmGenCntrl(): invalid"
511 " action=%d", cntrl->t.cntrl.action);
514 RgMiLrgSchCntrlCfm(cfmPst, cfm);
519 /***********************************************************
521 * Func : rgSCHLmmSapCntrl
524 * Desc : Processes the LM control request for STxxxSAP elmnt.
531 * File : rg_sch_lmm.c
533 **********************************************************/
534 Void rgSCHLmmSapCntrl
543 /* TODO Pass InstId instead of using InstId from cfmPst */
544 Inst inst = (cfmPst->srcInst - SCH_INST_START); /* Scheduler instance Id */
546 /* Only TFU SAP can be controlled by LM */
547 switch(cntrl->hdr.elmId.elmnt)
550 idx = (uint8_t)cntrl->t.cntrl.s.rgSapCntrl.suId;
551 if (idx > LRG_MAX_SAPS_PER_INST)
553 cfm->cfm.status = LCM_PRIM_NOK;
554 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
556 switch(cntrl->t.cntrl.action)
559 /* Bind Enable Request */
560 if ((rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_NOT_CFG) ||
561 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND))
563 cfm->cfm.status = LCM_PRIM_NOK;
564 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
568 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
570 rgSCHLmmStartTmr(inst, RGSCH_BNDREQ_TMR,
571 rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.val,
572 (PTR)&rgSchCb[inst].tfuSap[idx]);
574 /* Change SAP state */
575 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_WAIT_BNDCFM;
576 rgSchCb[inst].tfuSap[idx].numBndRetries++;
577 /* Store the response and TransId for sending
578 * the Control confirm */
579 memcpy(&rgSchCb[inst].genCfg.bndCfmResp[idx].response,
580 &cntrl->hdr.response, sizeof(Resp));
581 rgSchCb[inst].genCfg.bndCfmResp[idx].transId =
584 cfm->cfm.status = LCM_PRIM_OK_NDONE;
585 cfm->cfm.reason = LCM_REASON_NOT_APPL;
587 /* Sending Control Confirm before sending Bind
589 RgMiLrgSchCntrlCfm(cfmPst, cfm);
591 //rgSCHUtlTfuBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg.suId,
592 // rgSchCb[inst].tfuSap[idx].sapCfg.spId);
599 /* Check if the SAP is configured */
600 if( (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_NOT_CFG) ||
601 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_UNBND))
603 cfm->cfm.status = LCM_PRIM_NOK;
604 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
608 //rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg,
609 // TFU_UBNDREQ_MNGMT);
610 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
612 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR,
613 (PTR)&rgSchCb[inst].tfuSap[idx]);
615 /* Change SAP state */
616 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
617 cfm->cfm.status = LCM_PRIM_OK;
618 cfm->cfm.reason = LCM_REASON_NOT_APPL;
622 /* Delete SAP, does initialization of SAP */
623 if ((rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_WAIT_BNDCFM) ||
624 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND))
626 //rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg,
627 // TFU_UBNDREQ_MNGMT);
628 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
630 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR,
631 (PTR)&rgSchCb[inst].tfuSap[idx]);
634 memset(&rgSchCb[inst].tfuSap[idx], 0, sizeof(RgSchLowSapCb));
635 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_NOT_CFG;
636 cfm->cfm.status = LCM_PRIM_OK;
637 cfm->cfm.reason = LCM_REASON_NOT_APPL;
640 cfm->cfm.status = LCM_PRIM_NOK;
641 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
642 DU_LOG("\nERROR --> SCH : rgSCHLmmSapCntrl(): "
643 "invalid action=%d", cntrl->t.cntrl.action);
648 idx = (uint8_t)cntrl->t.cntrl.s.rgSapCntrl.spId;
649 if (idx > LRG_MAX_SAPS_PER_INST)
651 cfm->cfm.status = LCM_PRIM_NOK;
652 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
654 switch(cntrl->t.cntrl.action)
657 memset(&rgSchCb[inst].rgrSap[idx], 0, sizeof(RgSchUpSapCb));
658 rgSchCb[inst].rgrSap[idx].sapSta.sapState = LRG_NOT_CFG;
659 cfm->cfm.status = LCM_PRIM_OK;
660 cfm->cfm.reason = LCM_REASON_NOT_APPL;
663 cfm->cfm.status = LCM_PRIM_NOK;
664 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
665 DU_LOG("\nERROR --> SCH : rgSCHLmmSapCntrl(): "
666 "invalid action=%d", cntrl->t.cntrl.action);
671 idx = (uint8_t)cntrl->t.cntrl.s.rgSapCntrl.spId;
672 if (idx > LRG_MAX_SAPS_PER_INST)
674 cfm->cfm.status = LCM_PRIM_NOK;
675 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
677 switch(cntrl->t.cntrl.action)
680 memset(&rgSchCb[inst].rgmSap[idx], 0, sizeof(RgSchUpSapCb));
681 rgSchCb[inst].rgmSap[idx].sapSta.sapState = LRG_NOT_CFG;
682 cfm->cfm.status = LCM_PRIM_OK;
683 cfm->cfm.reason = LCM_REASON_NOT_APPL;
686 cfm->cfm.status = LCM_PRIM_NOK;
687 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
688 DU_LOG("\nERROR --> SCH : rgSCHLmmSapCntrl(): "
689 "invalid action=%d", cntrl->t.cntrl.action);
695 /* Would never come here. */
698 RgMiLrgSchCntrlCfm(cfmPst, cfm);
703 /***********************************************************
705 * Func : SchFillCfmPst
708 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
709 * and the cfm->hdr.response.
716 * File : rg_sch_lmm.c
718 **********************************************************/
728 inst = (reqPst->dstInst - SCH_INST_START);
730 cfmPst->srcEnt = ENTMAC;
731 cfmPst->srcInst = (Inst) 1;
732 cfmPst->srcProcId = rgSchCb[inst].rgSchInit.procId;
733 cfmPst->dstEnt = ENTMAC;
734 cfmPst->dstInst = (Inst) 0;
735 cfmPst->dstProcId = reqPst->srcProcId;
737 cfmPst->selector = cfm->hdr.response.selector;
738 cfmPst->region = cfm->hdr.response.mem.region;
739 cfmPst->pool = cfm->hdr.response.mem.pool;
746 * @brief Timer start handler.
750 * Function : rgSCHLmmStartTmr
752 * This function based on the input parameters starts the timer for
753 * "tmrVal" duration. As of now scheduler instance uses the timer
754 * functionality for BndReq only. Hence there is no conditional
755 * code based on "tmrEvnt".
757 * @param[in] S16 tmrEvnt, the Timer Event
758 * @param[in] uint32_t tmrVal, the Wait Time
759 * @param[in] PTR cb, Entry for which Timer expired
766 S16 tmrEvnt, /* Timer Event */
767 uint32_t tmrVal, /* Wait Time */
768 PTR cb /* Entry for which Timer Expired */
772 /* Inst dInst = inst + SCH_INST_START; */
776 /* Initialize the arg structure */
777 memset(&arg, 0, sizeof(CmTmrArg));
779 arg.tqCp = &rgSchCb[inst].tmrTqCp;
780 arg.tq = rgSchCb[inst].tmrTq;
781 arg.timers = &((RgSchLowSapCb *)cb)->tmrBlk;
784 arg.max = RGSCH_MAX_TIMER;
785 arg.evnt = RGSCH_BNDREQ_TMR;
794 * @brief Timer stop handler.
798 * Function : rgSCHLmmStopTmr
800 * This function based on the input parameters stops the timer for
801 * "tmrEvnt". As of now Scheduler instance uses the timer functionality for
802 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
803 * Once the bind happens and this timer is stopped, the timer functionality
804 * is deregistered with SSI. As there is no further use of timer processing.
806 * @param[in] S16 tmrEvnt, the Timer Event
807 * @param[in] PTR cb, Entry for which Timer expired
814 Inst inst, /* Scheduler instance */
815 S16 tmrEvnt, /* Timer Event */
816 PTR cb /* Entry for which Timer Expired */
825 for(i=0;i<RGSCH_MAX_TIMER;i++)
827 /* Search for the Timer Blocks */
828 if(((RgSchLowSapCb *)cb)->tmrBlk.tmrEvnt == tmrEvnt)
830 /* Initialize the arg structure */
831 memset(&arg, 0, sizeof(CmTmrArg));
833 arg.tqCp = &rgSchCb[inst].tmrTqCp;
834 arg.tq = rgSchCb[inst].tmrTq;
835 arg.timers = &(((RgSchLowSapCb *)cb)->tmrBlk);
837 arg.max = RGSCH_MAX_TIMER;
854 * @brief Timer Expiry handler.
858 * Function : rgSCHLmmTmrExpiry
860 * This is a callback function used as an input parameter to cmPrcTmr()
861 * to check expiry of any timer. In this function, we are only concerned
862 * about tmrEvnt=Bind timer.
864 * @param[in] PTR cb, Entry for which Timer expired
865 * @param[in] S16 tmrEvnt, the Timer Event
869 S16 rgSCHLmmTmrExpiry
871 PTR cb, /* Pointer to timer control block */
872 S16 tmrEvnt /* Timer Event */
876 RgSchLowSapCb *tfuSap = (RgSchLowSapCb *)cb;
881 case RGSCH_BNDREQ_TMR:
882 tfuSap->numBndRetries++;
883 if(tfuSap->numBndRetries > RGSCH_MAX_BNDRETRY)
885 rgSCHLmmStaInd((uint8_t)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
886 (uint16_t)LCM_CATEGORY_INTERFACE, (uint16_t)LCM_EVENT_BND_FAIL,
887 (uint16_t)LCM_CAUSE_TMR_EXPIRED, (RgUstaDgn *)NULLP);
891 /* Restart the bind timer */
892 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
894 ret = rgSCHLmmStartTmr((uint8_t)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
896 (uint32_t)tfuSap->sapCfg.bndTmr.val, cb);
899 /* Send bind request */
900 //rgSCHUtlTfuBndReq((uint8_t)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
901 //tfuSap->sapCfg.suId, tfuSap->sapCfg.spId);
905 DU_LOG("\nERROR --> SCH : rgSCHLmmTmrExpiry(): Invalid"
906 " tmrEvnt=%d", tmrEvnt);
915 * @brief Layer Manager Control Confirm generation handler
916 * for Bind Confirm reception at TFU interface.
917 * RgLiTfuBndCfm() forwards the confirmation to this
918 * function. All SAP state related handling is restricted
919 * to LMM modules, hence the cfm forwarding.
923 * Function : rgSCHLmmBndCfm
925 * This API is used by the LIM module of MAC to forward
926 * the Bind Confirm it receives over the TFU interface.
928 * @param[in] Pst *pst, Post Structure
929 * @param[in] SuId suId, Service user ID
930 * @param[in] uint8_t status, Status
936 Pst *pst, /* Post Structure */
937 SuId suId, /* Service user ID */
938 uint8_t status /* Status */
944 Inst inst = (pst->dstInst - SCH_INST_START); /* scheduler instance */
947 /* check the SAP State */
948 switch(rgSchCb[inst].tfuSap[suId].sapSta.sapState)
950 case LRG_WAIT_BNDCFM:
953 /* SAP is already bound */
959 cfmPst = rgSchCb[inst].rgSchInit.lmPst;
960 cfmPst.selector = rgSchCb[inst].genCfg.bndCfmResp[suId].response.selector;
961 cfmPst.prior = rgSchCb[inst].genCfg.bndCfmResp[suId].response.prior;
962 cfmPst.route = rgSchCb[inst].genCfg.bndCfmResp[suId].response.route;
963 cfmPst.region = rgSchCb[inst].genCfg.bndCfmResp[suId].response.mem.region;
964 cfmPst.pool = rgSchCb[inst].genCfg.bndCfmResp[suId].response.mem.pool;
966 memset(&cntrlCfm, 0, sizeof(RgMngmt));
970 case CM_BND_OK: /* status is OK */
971 /* Change SAP state to Bound */
972 rgSchCb[inst].tfuSap[suId].sapSta.sapState = LRG_BND;
973 if (rgSchCb[inst].tfuSap[suId].sapCfg.bndTmr.enb == TRUE)
975 ret = rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[suId]);
977 /* Send Control Confirm with status as OK to Layer Manager */
978 cntrlCfm.cfm.status = LCM_PRIM_OK;
979 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
980 /* Sending Status Indication to Layer Manager */
981 rgSCHLmmStaInd((uint8_t)(rgSchCb[inst].tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
982 LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_OK,
983 LCM_CAUSE_LYR_SPECIFIC, (RgUstaDgn *)NULLP);
987 /* Change SAP state to UnBound */
988 rgSchCb[inst].tfuSap[suId].sapSta.sapState = LRG_UNBND;
989 if (rgSchCb[inst].tfuSap[suId].sapCfg.bndTmr.enb == TRUE)
991 ret = rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[suId]);
993 /* Send Control Confirm with status as NOK to Layer Manager */
994 cntrlCfm.cfm.status = LCM_PRIM_NOK;
995 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
998 rgSchCb[inst].tfuSap[suId].numBndRetries = 0;
999 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1000 cntrlCfm.hdr.transId = rgSchCb[inst].genCfg.bndCfmResp[suId].transId;
1002 ret = RgMiLrgSchCntrlCfm(&cfmPst, &cntrlCfm);
1008 * @brief Layer Manager Unsolicited Status Indication generation.
1012 * Function : rgSCHLmmStaInd
1014 * This API is used by the other modules of MAC to send a unsolicited
1015 * status indication to the Layer Manager.
1017 * @param[in] uint16_t category, the Alarm category
1018 * @param[in] uint16_t event, the Alarm event
1019 * @param[in] uint16_t cause, the cause of the Alarm
1020 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1035 if(rgSchCb[inst].rgSchInit.usta == FALSE)
1039 memset(&usta, 0, sizeof(RgMngmt));
1041 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1042 usta.t.usta.cmAlarm.category = category;
1043 usta.t.usta.cmAlarm.event = event;
1044 usta.t.usta.cmAlarm.cause = cause;
1047 memcpy(&usta.t.usta.dgn, dgn, sizeof(RgUstaDgn));
1050 rgSchCb[inst].rgSchInit.lmPst.selector =
1051 rgSchCb[inst].genCfg.ustaResp.response.selector;
1052 rgSchCb[inst].rgSchInit.lmPst.prior =
1053 rgSchCb[inst].genCfg.ustaResp.response.prior;
1054 rgSchCb[inst].rgSchInit.lmPst.route =
1055 rgSchCb[inst].genCfg.ustaResp.response.route;
1056 rgSchCb[inst].rgSchInit.lmPst.region =
1057 rgSchCb[inst].genCfg.ustaResp.response.mem.region;
1058 rgSchCb[inst].rgSchInit.lmPst.pool =
1059 rgSchCb[inst].genCfg.ustaResp.response.mem.pool;
1060 usta.hdr.transId = rgSchCb[inst].genCfg.ustaResp.transId;
1062 return (RgMiLrgSchStaInd(&rgSchCb[inst].rgSchInit.lmPst, &usta));
1067 * @brief Scheduler instance timer call back function registered with SSI.
1071 * Function : schActvTmr
1073 * This function is invoked by SSI for every timer activation
1074 * period expiry. Note that SS_MT_TMR flag needs to be enabled for this
1075 * as isntId is needed.As part of SRegTmr call for scheduler instance
1076 * SS_MT_TMR flag needs to be enabled and schActvTmr needs to be given as
1082 S16 schActvTmr(Ent ent,Inst inst)
1084 Inst schInst = (inst - SCH_INST_START);
1086 /* Check if any timer in the scheduler instance has expired */
1087 cmPrcTmr(&rgSchCb[schInst].tmrTqCp,
1088 rgSchCb[schInst].tmrTq, (PFV) rgSCHLmmTmrExpiry);
1092 } /* end of schActvTmr */
1095 /**********************************************************************
1098 **********************************************************************/