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.
37 static const char* RLOG_MODULE_NAME="MAC";
38 static int RLOG_MODULE_ID=4096;
39 static int RLOG_FILE_ID=167;
41 /* header include files (.h) */
42 #include "common_def.h"
43 #include "rg_env.h" /* MAC Environment Defines */
44 #include "rgr.h" /* RGR Interface defines */
45 #include "tfu.h" /* RGU Interface defines */
46 #include "lrg.h" /* LRG Interface defines */
47 #include "rgm.h" /* RGM Interface defines */
48 #include "rg_sch.h" /* Scheduler defines */
49 #include "rg_sch_inf.h" /* Scheduler defines */
50 #include "rg_sch_err.h" /* MAC error defines */
52 #include "rg_sch_cmn.h" /* typedefs for Scheduler */
54 #include "rl_interface.h"
55 #include "rl_common.h"
57 /* header/extern include files (.x) */
58 #include "rgr.x" /* RGR Interface includes */
59 #include "rgm.x" /* RGM Interface includes */
60 #include "tfu.x" /* RGU Interface includes */
61 #include "lrg.x" /* LRG Interface includes */
62 #include "rg_sch_inf.x" /* Scheduler defines */
63 #include "rg_sch.x" /* Scheduler includes */
65 #include "rg_sch_cmn.x" /* typedefs for Scheduler */
68 Void rgSCHCmnInit ARGS((Void));
70 /* forward references */
71 extern int schActvInit(Ent entity, Inst instId, Region region, Reason reason);
73 PRIVATE uint16_t rgSCHLmmSapCfg ARGS((
80 PRIVATE Void rgSCHLmmShutdown ARGS((
85 void printSchCellInfo(void)
89 for (idx = 0; idx < rgSchCb[inst].numSaps; idx++)
91 /* Unbind all the TFU SAP */
92 /* Free the memory held by the cell associated
94 if (rgSchCb[inst].tfuSap[idx].cell != NULLP)
96 RLOG1(L_INFO,"CELL %d\n", idx);
97 RLOG1(L_INFO,"NUM UEs :%d\n",rgSchCb[inst].tfuSap[idx].cell->ueLst.nmbEnt);
103 * @brief SAP Configuration Handler.
107 * Function : rgSCHLmmSapCfg
109 * This function in called by SchProcGenCfgReq(). It handles the
110 * interface SAP configuration of the scheduler instance. It
111 * initializes the sapState to LRG_UNBND. Returns
112 * reason for success/failure of this function.
114 * @param[in] RgCfg *cfg, the Configuaration information
116 * -# LCM_REASON_GENCFG_NOT_DONE
117 * -# LCM_REASON_INVALID_SAP
118 * -# LCM_REASON_NOT_APPL
122 PRIVATE uint16_t rgSCHLmmSapCfg
125 RgCfg *cfg, /* Configuaration information */
126 uint8_t sapIdx, /* SAP index */
127 Elmnt sapType /* SAP Type */
130 PRIVATE uint16_t rgSCHLmmSapCfg(dInst, cfg, sapIdx, sapType)
132 RgCfg *cfg; /* Configuaration information */
133 uint8_t sapIdx; /* SAP index */
134 Elmnt sapType; /* SAP Type */
137 uint16_t ret = LCM_REASON_NOT_APPL;
138 RgSchLowSapCfgInfo *lowSapCfg = NULLP;
139 RgSchUpSapCfgInfo *upSapCfg = NULLP;
140 Inst inst = (dInst - SCH_INST_START);
142 /* Check if Gen Config has been done */
148 if ((cfg->s.schInstCfg.rgrSap[sapIdx].selector != ODU_SELECTOR_TC) &&
149 (cfg->s.schInstCfg.rgrSap[sapIdx].selector != ODU_SELECTOR_LC))
151 ret = LCM_REASON_INVALID_PAR_VAL;
152 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
153 " Selector value for RGR.");
157 if(rgSchCb[inst].rgrSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
159 rgSchCb[inst].rgrSap[sapIdx].sapSta.sapState = LRG_UNBND;
161 upSapCfg = &rgSchCb[inst].rgrSap[sapIdx].sapCfg;
163 upSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.rgrSap[sapIdx].ent;
164 upSapCfg->sapPst.dstInst = cfg->s.schInstCfg.rgrSap[sapIdx].inst;
165 upSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.rgrSap[sapIdx].procId;
166 upSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
167 upSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
169 upSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
170 upSapCfg->sapPst.region = cfg->s.schInstCfg.rgrSap[sapIdx].mem.region;
171 upSapCfg->sapPst.pool = cfg->s.schInstCfg.rgrSap[sapIdx].mem.pool;
172 upSapCfg->sapPst.selector = cfg->s.schInstCfg.rgrSap[sapIdx].selector;
173 upSapCfg->sapPst.route = cfg->s.schInstCfg.rgrSap[sapIdx].route;
174 upSapCfg->sapPst.intfVer = 0;
175 upSapCfg->sapPst.event = 0;
176 upSapCfg->sapPst.prior = cfg->s.schInstCfg.rgrSap[sapIdx].prior;
177 upSapCfg->suId = cfg->s.schInstCfg.rgrSap[sapIdx].suId;
178 upSapCfg->spId = cfg->s.schInstCfg.rgrSap[sapIdx].spId;
182 if ((cfg->s.schInstCfg.tfuSap[sapIdx].selector != ODU_SELECTOR_TC) &&
183 (cfg->s.schInstCfg.tfuSap[sapIdx].selector != ODU_SELECTOR_LC))
185 ret = LCM_REASON_INVALID_PAR_VAL;
186 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
187 " Selector value for TFU.");
191 if (rgSchCb[inst].tfuSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
193 rgSchCb[inst].tfuSap[sapIdx].sapSta.sapState = LRG_UNBND;
195 /* Initialize the sap timer */
196 cmInitTimers(&(rgSchCb[inst].tfuSap[sapIdx].tmrBlk), 1);
197 lowSapCfg = &rgSchCb[inst].tfuSap[sapIdx].sapCfg;
199 lowSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.tfuSap[sapIdx].ent;
200 lowSapCfg->sapPst.dstInst = cfg->s.schInstCfg.tfuSap[sapIdx].inst;
201 lowSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.tfuSap[sapIdx].procId;
202 lowSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
203 lowSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
205 lowSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
206 lowSapCfg->sapPst.region = cfg->s.schInstCfg.tfuSap[sapIdx].mem.region;
207 lowSapCfg->sapPst.pool = cfg->s.schInstCfg.tfuSap[sapIdx].mem.pool;
208 lowSapCfg->sapPst.selector = cfg->s.schInstCfg.tfuSap[sapIdx].selector;
209 lowSapCfg->sapPst.route = cfg->s.schInstCfg.tfuSap[sapIdx].route;
210 lowSapCfg->sapPst.intfVer = 0;
211 lowSapCfg->sapPst.event = 0;
212 lowSapCfg->sapPst.prior = cfg->s.schInstCfg.tfuSap[sapIdx].prior;
213 lowSapCfg->suId = cfg->s.schInstCfg.tfuSap[sapIdx].suId;
214 lowSapCfg->spId = cfg->s.schInstCfg.tfuSap[sapIdx].spId;
215 memcpy(&lowSapCfg->bndTmr,
216 &cfg->s.schInstCfg.tfuSap[sapIdx].bndTmr,
221 if ((cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_LWLC) &&
222 (cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_LC) &&
223 (cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_TC))
225 ret = LCM_REASON_INVALID_PAR_VAL;
226 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
227 " Selector value for RGM.");
231 if (rgSchCb[inst].rgmSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
233 rgSchCb[inst].rgmSap[sapIdx].sapSta.sapState = LRG_UNBND;
235 upSapCfg = &rgSchCb[inst].rgmSap[sapIdx].sapCfg;
236 upSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.rgmSap[sapIdx].ent;
237 upSapCfg->sapPst.dstInst = cfg->s.schInstCfg.rgmSap[sapIdx].inst;
238 upSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.rgmSap[sapIdx].procId;
239 upSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
240 upSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
242 upSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
243 upSapCfg->sapPst.region = cfg->s.schInstCfg.rgmSap[sapIdx].mem.region;
244 upSapCfg->sapPst.pool = cfg->s.schInstCfg.rgmSap[sapIdx].mem.pool;
245 upSapCfg->sapPst.selector = cfg->s.schInstCfg.rgmSap[sapIdx].selector;
246 upSapCfg->sapPst.route = cfg->s.schInstCfg.rgmSap[sapIdx].route;
247 upSapCfg->sapPst.intfVer = 0;
248 upSapCfg->sapPst.event = 0;
249 upSapCfg->sapPst.prior = cfg->s.schInstCfg.rgmSap[sapIdx].prior;
250 upSapCfg->suId = cfg->s.schInstCfg.rgmSap[sapIdx].suId;
251 upSapCfg->spId = cfg->s.schInstCfg.rgmSap[sapIdx].spId;
255 /* would never reach here */
262 /***********************************************************
264 * Func : rgSCHLmmShutdown
267 * Desc : Handles the scheduler instance shutdown request. Calls
268 * rgSCHCfgFreeCellCb(RgSchCellCb*) to handle each cellCb deallocation.
275 * File : rg_sch_lmm.c
277 **********************************************************/
279 PRIVATE Void rgSCHLmmShutdown
284 PRIVATE Void rgSCHLmmShutdown(inst)
288 Inst dInst = inst + SCH_INST_START;
291 CmLList *lnk = NULLP;
292 RgSchCb *instCb = &rgSchCb[inst];
293 RgSchCellCb *cell = NULLP;
294 RgSchL2MeasCb *measCb;
296 RgSchCmnUlCell *cellUl;
297 RgSchClcBoRpt *bo = NULL;
301 for (idx = 0; idx < instCb->numSaps; idx++)
303 /* got the cell break the loop */
304 cell = instCb->rgrSap[idx].cell;
307 /* Free the memory held up by ulAllocInfo */
308 cellUl = RG_SCH_CMN_GET_UL_CELL(cell);
310 for(ulAllocIdx = 0; ulAllocIdx < RGSCH_SF_ALLOC_SIZE; ulAllocIdx++)
312 for(ulAllocIdx = 0; ulAllocIdx < RGSCH_NUM_SUB_FRAMES; ulAllocIdx++)
315 if(cell->sfAllocArr[ulAllocIdx].ulUeInfo.ulAllocInfo != NULLP)
317 /* ccpu00117052 - MOD - Passing double pointer
318 for proper NULLP assignment*/
319 rgSCHUtlFreeSBuf(cell->instIdx,
320 (Data **)(&(cell->sfAllocArr[ulAllocIdx].ulUeInfo.\
322 cellUl->maxAllocPerUlSf * sizeof(RgInfUeUlAlloc));
325 /* Free the memory allocated to measCb */
326 lnk = cell->l2mList.first;
329 measCb = (RgSchL2MeasCb *)lnk->node;
330 cmLListDelFrm(&cell->l2mList, lnk);
332 /* ccpu00117052 - MOD - Passing double pointer
333 for proper NULLP assignment*/
334 rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&measCb,\
335 sizeof(RgSchL2MeasCb));
338 /* Free mem if any present for boLst for common channels */
339 for(idx = 0; idx < RGSCH_MAX_CMN_LC_CB; idx++)
341 lnk = (CmLList *)cell->cmnLcCb[idx].boLst.first;
344 bo = (RgSchClcBoRpt *)(lnk->node);
346 cmLListDelFrm(&cell->cmnLcCb[idx].boLst, &bo->boLstEnt);
347 rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&bo, sizeof(RgSchClcBoRpt));
355 rgSCHLaaDeInitEnbCb(&rgSchCb[inst]);
357 for (idx = 0; idx < rgSchCb[inst].numSaps; idx++)
359 /* Unbind all the TFU SAP */
360 if(rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_WAIT_BNDCFM)
362 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg, LRG_UNBND);
363 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
365 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[idx]);
367 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
369 if(rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND)
371 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg, LRG_UNBND);
372 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
374 /* Free the memory held by the cell associated with this SAP */
375 if (rgSchCb[inst].tfuSap[idx].cell != NULLP)
376 rgSCHCfgFreeCellCb(rgSchCb[inst].tfuSap[idx].cell);
377 rgSchCb[inst].tfuSap[idx].cell = NULLP;
379 /* Free the memory held by the scheduler instance */
380 /* Deallocate RGR saps */
381 SPutSBuf(rgSchCb[inst].rgSchInit.region,
382 rgSchCb[inst].rgSchInit.pool,
383 (Data *)rgSchCb[inst].rgrSap,
384 (sizeof(RgSchUpSapCb) * rgSchCb[inst].numSaps));
385 rgSchCb[inst].rgrSap = NULLP;
386 /* Deallocate RGM saps */
387 SPutSBuf(rgSchCb[inst].rgSchInit.region,
388 rgSchCb[inst].rgSchInit.pool,
389 (Data *)rgSchCb[inst].rgmSap,
390 (sizeof(RgSchUpSapCb) * rgSchCb[inst].numSaps));
391 rgSchCb[inst].rgmSap = NULLP;
393 /* Deallocate TFU saps */
394 SPutSBuf(rgSchCb[inst].rgSchInit.region,
395 rgSchCb[inst].rgSchInit.pool,
396 (Data *)rgSchCb[inst].tfuSap,
397 (sizeof(RgSchLowSapCb) * rgSchCb[inst].numSaps));
398 rgSchCb[inst].tfuSap = NULLP;
400 /* Deallocate bndCfmResponses */
401 SPutSBuf(rgSchCb[inst].rgSchInit.region,
402 rgSchCb[inst].rgSchInit.pool,
403 (Data *)rgSchCb[inst].genCfg.bndCfmResp,
404 (sizeof(RgSchLmResponse) * rgSchCb[inst].numSaps));
405 rgSchCb[inst].genCfg.bndCfmResp = NULLP;
406 /* De-register the Timer Service */
407 (Void) SDeregTmrMt(rgSchCb[inst].rgSchInit.ent, dInst,
408 (S16)rgSchCb[inst].genCfg.tmrRes, schActvTmr);
410 /* call back the task initialization function to intialize
411 * the global rgSchCb[inst] Struct */
412 schActvInit(rgSchCb[inst].rgSchInit.ent, dInst, rgSchCb[inst].rgSchInit.region,
413 rgSchCb[inst].rgSchInit.reason);
415 /* Set Config done in TskInit */
416 rgSchCb[inst].rgSchInit.cfgDone = FALSE;
422 /***********************************************************
424 * Func : rgSCHLmmGenCntrl
427 * Desc : Processes the LM control request for STGEN elmnt.
434 * File : rg_sch_lmm.c
436 **********************************************************/
438 Void rgSCHLmmGenCntrl
445 Void rgSCHLmmGenCntrl(cntrl, cfm, cfmPst)
451 Inst inst = (cfmPst->srcInst - SCH_INST_START); /* Scheduler instance ID */
453 cfm->cfm.status = LCM_PRIM_OK;
454 cfm->cfm.reason = LCM_REASON_NOT_APPL;
457 switch(cntrl->t.cntrl.action)
460 /* Action is Enable */
461 switch(cntrl->t.cntrl.subAction)
464 /* Enable Unsolicited Status (alarms) */
465 rgSchCb[inst].rgSchInit.usta = TRUE;
466 /*Store the response and TransId for sending the Alarms */
467 memcpy(&rgSchCb[inst].genCfg.ustaResp.response,
468 &cntrl->hdr.response, sizeof(Resp));
469 rgSchCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
472 /* Enable Debug Printing */
474 rgSchCb[inst].rgSchInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
477 #ifdef PHY_ERROR_LOGING
480 rgSchUlAllocCntr.mcs = cntrl->t.cntrl.s.rgSchUlAllocCntrl.mcs;
481 rgSchUlAllocCntr.numOfRb = cntrl->t.cntrl.s.rgSchUlAllocCntrl.numOfRb;
482 rgSchUlAllocCntr.rbStart = cntrl->t.cntrl.s.rgSchUlAllocCntrl.rbStart;
483 rgSchUlAllocCntr.testStart = cntrl->t.cntrl.s.rgSchUlAllocCntrl.testStart;
484 rgSchUlAllocCntr.enaLog = cntrl->t.cntrl.s.rgSchUlAllocCntrl.enaLog;
485 rgSchUlAllocCntr.logTime = cntrl->t.cntrl.s.rgSchUlAllocCntrl.logTime;
486 rgSchUlAllocCntr.crcOk = 0;
487 rgSchUlAllocCntr.crcErr = 0;
488 rgSchUlAllocCntr.numUlPackets = 0;
489 rgSchUlAllocCntr.numPrach = 0;
490 rgSchUlAllocCntr.taZero = 0;
496 memset(&hqRetxStats, 0, sizeof(RgSchHqRetxStats));
497 memset(&hqFailStats, 0, sizeof(RgSchNackAckStats));
503 cfm->cfm.status = LCM_PRIM_NOK;
504 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
505 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl(): "
506 "invalid subaction=%d", cntrl->t.cntrl.subAction);
511 /* Action is Diable immidiately */
512 switch(cntrl->t.cntrl.subAction)
515 /* Disable Unsolicited Status (alarms) */
516 rgSchCb[inst].rgSchInit.usta = FALSE;
519 /* Disable Debug Printing */
521 rgSchCb[inst].rgSchInit.dbgMask &=\
522 ~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
527 cfm->cfm.status = LCM_PRIM_NOK;
528 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
529 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl():"
530 " invalid subaction=%d", cntrl->t.cntrl.subAction);
535 /* Free all the memory dynamically allocated by MAC */
536 rgSCHLmmShutdown(inst);
539 cfm->cfm.status = LCM_PRIM_NOK;
540 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
541 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl(): invalid"
542 " action=%d", cntrl->t.cntrl.action);
545 RgMiLrgSchCntrlCfm(cfmPst, cfm);
550 /***********************************************************
552 * Func : rgSCHLmmSapCntrl
555 * Desc : Processes the LM control request for STxxxSAP elmnt.
562 * File : rg_sch_lmm.c
564 **********************************************************/
566 Void rgSCHLmmSapCntrl
573 Void rgSCHLmmSapCntrl(cntrl, cfm, cfmPst)
581 /* TODO Pass InstId instead of using InstId from cfmPst */
582 Inst inst = (cfmPst->srcInst - SCH_INST_START); /* Scheduler instance Id */
584 /* Only TFU SAP can be controlled by LM */
585 switch(cntrl->hdr.elmId.elmnt)
588 idx = (uint8_t)cntrl->t.cntrl.s.rgSapCntrl.suId;
589 if (idx > LRG_MAX_SAPS_PER_INST)
591 cfm->cfm.status = LCM_PRIM_NOK;
592 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
594 switch(cntrl->t.cntrl.action)
597 /* Bind Enable Request */
598 if ((rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_NOT_CFG) ||
599 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND))
601 cfm->cfm.status = LCM_PRIM_NOK;
602 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
606 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
608 rgSCHLmmStartTmr(inst, RGSCH_BNDREQ_TMR,
609 rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.val,
610 (PTR)&rgSchCb[inst].tfuSap[idx]);
612 /* Change SAP state */
613 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_WAIT_BNDCFM;
614 rgSchCb[inst].tfuSap[idx].numBndRetries++;
615 /* Store the response and TransId for sending
616 * the Control confirm */
617 memcpy(&rgSchCb[inst].genCfg.bndCfmResp[idx].response,
618 &cntrl->hdr.response, sizeof(Resp));
619 rgSchCb[inst].genCfg.bndCfmResp[idx].transId =
622 cfm->cfm.status = LCM_PRIM_OK_NDONE;
623 cfm->cfm.reason = LCM_REASON_NOT_APPL;
625 /* Sending Control Confirm before sending Bind
627 RgMiLrgSchCntrlCfm(cfmPst, cfm);
629 rgSCHUtlTfuBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg.suId,
630 rgSchCb[inst].tfuSap[idx].sapCfg.spId);
637 /* Check if the SAP is configured */
638 if( (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_NOT_CFG) ||
639 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_UNBND))
641 cfm->cfm.status = LCM_PRIM_NOK;
642 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
646 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg,
648 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
650 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR,
651 (PTR)&rgSchCb[inst].tfuSap[idx]);
653 /* Change SAP state */
654 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
655 cfm->cfm.status = LCM_PRIM_OK;
656 cfm->cfm.reason = LCM_REASON_NOT_APPL;
660 /* Delete SAP, does initialization of SAP */
661 if ((rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_WAIT_BNDCFM) ||
662 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND))
664 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg,
666 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
668 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR,
669 (PTR)&rgSchCb[inst].tfuSap[idx]);
672 memset(&rgSchCb[inst].tfuSap[idx], 0, sizeof(RgSchLowSapCb));
673 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_NOT_CFG;
674 cfm->cfm.status = LCM_PRIM_OK;
675 cfm->cfm.reason = LCM_REASON_NOT_APPL;
678 cfm->cfm.status = LCM_PRIM_NOK;
679 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
680 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
681 "invalid action=%d", cntrl->t.cntrl.action);
686 idx = (uint8_t)cntrl->t.cntrl.s.rgSapCntrl.spId;
687 if (idx > LRG_MAX_SAPS_PER_INST)
689 cfm->cfm.status = LCM_PRIM_NOK;
690 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
692 switch(cntrl->t.cntrl.action)
695 memset(&rgSchCb[inst].rgrSap[idx], 0, sizeof(RgSchUpSapCb));
696 rgSchCb[inst].rgrSap[idx].sapSta.sapState = LRG_NOT_CFG;
697 cfm->cfm.status = LCM_PRIM_OK;
698 cfm->cfm.reason = LCM_REASON_NOT_APPL;
701 cfm->cfm.status = LCM_PRIM_NOK;
702 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
703 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
704 "invalid action=%d", cntrl->t.cntrl.action);
709 idx = (uint8_t)cntrl->t.cntrl.s.rgSapCntrl.spId;
710 if (idx > LRG_MAX_SAPS_PER_INST)
712 cfm->cfm.status = LCM_PRIM_NOK;
713 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
715 switch(cntrl->t.cntrl.action)
718 memset(&rgSchCb[inst].rgmSap[idx], 0, sizeof(RgSchUpSapCb));
719 rgSchCb[inst].rgmSap[idx].sapSta.sapState = LRG_NOT_CFG;
720 cfm->cfm.status = LCM_PRIM_OK;
721 cfm->cfm.reason = LCM_REASON_NOT_APPL;
724 cfm->cfm.status = LCM_PRIM_NOK;
725 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
726 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
727 "invalid action=%d", cntrl->t.cntrl.action);
733 /* Would never come here. */
736 RgMiLrgSchCntrlCfm(cfmPst, cfm);
741 /***********************************************************
743 * Func : SchFillCfmPst
746 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
747 * and the cfm->hdr.response.
754 * File : rg_sch_lmm.c
756 **********************************************************/
765 Void SchFillCfmPst(reqPst, cfmPst, cfm)
773 inst = (reqPst->dstInst - SCH_INST_START);
775 cfmPst->srcEnt = ENTMAC;
776 cfmPst->srcInst = (Inst) 1;
777 cfmPst->srcProcId = rgSchCb[inst].rgSchInit.procId;
778 cfmPst->dstEnt = ENTMAC;
779 cfmPst->dstInst = (Inst) 0;
780 cfmPst->dstProcId = reqPst->srcProcId;
782 cfmPst->selector = cfm->hdr.response.selector;
783 cfmPst->region = cfm->hdr.response.mem.region;
784 cfmPst->pool = cfm->hdr.response.mem.pool;
791 * @brief Timer start handler.
795 * Function : rgSCHLmmStartTmr
797 * This function based on the input parameters starts the timer for
798 * "tmrVal" duration. As of now scheduler instance uses the timer
799 * functionality for BndReq only. Hence there is no conditional
800 * code based on "tmrEvnt".
802 * @param[in] S16 tmrEvnt, the Timer Event
803 * @param[in] uint32_t tmrVal, the Wait Time
804 * @param[in] PTR cb, Entry for which Timer expired
812 S16 tmrEvnt, /* Timer Event */
813 uint32_t tmrVal, /* Wait Time */
814 PTR cb /* Entry for which Timer Expired */
817 S16 rgSCHLmmStartTmr(inst, tmrEvnt, tmrVal, cb)
818 Inst inst; /* scheduler instance ID */
819 S16 tmrEvnt; /* Timer Event */
820 uint32_t tmrVal; /* Wait Time */
821 PTR cb; /* Entry for which Timer Expired */
825 /* Inst dInst = inst + SCH_INST_START; */
829 /* Initialize the arg structure */
830 memset(&arg, 0, sizeof(CmTmrArg));
832 arg.tqCp = &rgSchCb[inst].tmrTqCp;
833 arg.tq = rgSchCb[inst].tmrTq;
834 arg.timers = &((RgSchLowSapCb *)cb)->tmrBlk;
837 arg.max = RGSCH_MAX_TIMER;
838 arg.evnt = RGSCH_BNDREQ_TMR;
847 * @brief Timer stop handler.
851 * Function : rgSCHLmmStopTmr
853 * This function based on the input parameters stops the timer for
854 * "tmrEvnt". As of now Scheduler instance uses the timer functionality for
855 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
856 * Once the bind happens and this timer is stopped, the timer functionality
857 * is deregistered with SSI. As there is no further use of timer processing.
859 * @param[in] S16 tmrEvnt, the Timer Event
860 * @param[in] PTR cb, Entry for which Timer expired
868 Inst inst, /* Scheduler instance */
869 S16 tmrEvnt, /* Timer Event */
870 PTR cb /* Entry for which Timer Expired */
873 S16 rgSCHLmmStopTmr(inst, tmrEvnt, cb)
874 Inst inst; /* Scheduler instance */
875 S16 tmrEvnt; /* Timer Event */
876 PTR cb; /* Entry for which Timer Expired */
885 for(i=0;i<RGSCH_MAX_TIMER;i++)
887 /* Search for the Timer Blocks */
888 if(((RgSchLowSapCb *)cb)->tmrBlk.tmrEvnt == tmrEvnt)
890 /* Initialize the arg structure */
891 memset(&arg, 0, sizeof(CmTmrArg));
893 arg.tqCp = &rgSchCb[inst].tmrTqCp;
894 arg.tq = rgSchCb[inst].tmrTq;
895 arg.timers = &(((RgSchLowSapCb *)cb)->tmrBlk);
897 arg.max = RGSCH_MAX_TIMER;
914 * @brief Timer Expiry handler.
918 * Function : rgSCHLmmTmrExpiry
920 * This is a callback function used as an input parameter to cmPrcTmr()
921 * to check expiry of any timer. In this function, we are only concerned
922 * about tmrEvnt=Bind timer.
924 * @param[in] PTR cb, Entry for which Timer expired
925 * @param[in] S16 tmrEvnt, the Timer Event
930 S16 rgSCHLmmTmrExpiry
932 PTR cb, /* Pointer to timer control block */
933 S16 tmrEvnt /* Timer Event */
936 S16 rgSCHLmmTmrExpiry(cb,tmrEvnt)
937 PTR cb; /* Pointer to timer control block */
938 S16 tmrEvnt; /* Timer Event */
942 RgSchLowSapCb *tfuSap = (RgSchLowSapCb *)cb;
944 Inst inst = tfuSap->cell->instIdx;
950 case RGSCH_BNDREQ_TMR:
951 tfuSap->numBndRetries++;
952 if(tfuSap->numBndRetries > RGSCH_MAX_BNDRETRY)
954 rgSCHLmmStaInd((uint8_t)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
955 (uint16_t)LCM_CATEGORY_INTERFACE, (uint16_t)LCM_EVENT_BND_FAIL,
956 (uint16_t)LCM_CAUSE_TMR_EXPIRED, (RgUstaDgn *)NULLP);
960 /* Restart the bind timer */
961 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
963 ret = rgSCHLmmStartTmr((uint8_t)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
965 (uint32_t)tfuSap->sapCfg.bndTmr.val, cb);
968 /* Send bind request */
969 rgSCHUtlTfuBndReq((uint8_t)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
970 tfuSap->sapCfg.suId, tfuSap->sapCfg.spId);
974 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmTmrExpiry(): Invalid"
975 " tmrEvnt=%d", tmrEvnt);
984 * @brief Layer Manager Control Confirm generation handler
985 * for Bind Confirm reception at TFU interface.
986 * RgLiTfuBndCfm() forwards the confirmation to this
987 * function. All SAP state related handling is restricted
988 * to LMM modules, hence the cfm forwarding.
992 * Function : rgSCHLmmBndCfm
994 * This API is used by the LIM module of MAC to forward
995 * the Bind Confirm it receives over the TFU interface.
997 * @param[in] Pst *pst, Post Structure
998 * @param[in] SuId suId, Service user ID
999 * @param[in] uint8_t status, Status
1006 Pst *pst, /* Post Structure */
1007 SuId suId, /* Service user ID */
1008 uint8_t status /* Status */
1011 S16 rgSCHLmmBndCfm(pst,suId,status)
1012 Pst *pst; /* Post Structure */
1013 SuId suId; /* Service user Id */
1014 uint8_t status; /* Status */
1020 Inst inst = (pst->dstInst - SCH_INST_START); /* scheduler instance */
1023 /* check the SAP State */
1024 switch(rgSchCb[inst].tfuSap[suId].sapSta.sapState)
1026 case LRG_WAIT_BNDCFM:
1029 /* SAP is already bound */
1035 cfmPst = rgSchCb[inst].rgSchInit.lmPst;
1036 cfmPst.selector = rgSchCb[inst].genCfg.bndCfmResp[suId].response.selector;
1037 cfmPst.prior = rgSchCb[inst].genCfg.bndCfmResp[suId].response.prior;
1038 cfmPst.route = rgSchCb[inst].genCfg.bndCfmResp[suId].response.route;
1039 cfmPst.region = rgSchCb[inst].genCfg.bndCfmResp[suId].response.mem.region;
1040 cfmPst.pool = rgSchCb[inst].genCfg.bndCfmResp[suId].response.mem.pool;
1042 memset(&cntrlCfm, 0, sizeof(RgMngmt));
1046 case CM_BND_OK: /* status is OK */
1047 /* Change SAP state to Bound */
1048 rgSchCb[inst].tfuSap[suId].sapSta.sapState = LRG_BND;
1049 if (rgSchCb[inst].tfuSap[suId].sapCfg.bndTmr.enb == TRUE)
1051 ret = rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[suId]);
1053 /* Send Control Confirm with status as OK to Layer Manager */
1054 cntrlCfm.cfm.status = LCM_PRIM_OK;
1055 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1056 /* Sending Status Indication to Layer Manager */
1057 rgSCHLmmStaInd((uint8_t)(rgSchCb[inst].tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
1058 LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_OK,
1059 LCM_CAUSE_LYR_SPECIFIC, (RgUstaDgn *)NULLP);
1063 /* Change SAP state to UnBound */
1064 rgSchCb[inst].tfuSap[suId].sapSta.sapState = LRG_UNBND;
1065 if (rgSchCb[inst].tfuSap[suId].sapCfg.bndTmr.enb == TRUE)
1067 ret = rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[suId]);
1069 /* Send Control Confirm with status as NOK to Layer Manager */
1070 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1071 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1074 rgSchCb[inst].tfuSap[suId].numBndRetries = 0;
1075 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1076 cntrlCfm.hdr.transId = rgSchCb[inst].genCfg.bndCfmResp[suId].transId;
1078 ret = RgMiLrgSchCntrlCfm(&cfmPst, &cntrlCfm);
1084 * @brief Layer Manager Unsolicited Status Indication generation.
1088 * Function : rgSCHLmmStaInd
1090 * This API is used by the other modules of MAC to send a unsolicited
1091 * status indication to the Layer Manager.
1093 * @param[in] uint16_t category, the Alarm category
1094 * @param[in] uint16_t event, the Alarm event
1095 * @param[in] uint16_t cause, the cause of the Alarm
1096 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1110 S16 rgSCHLmmStaInd(inst, category, event, cause, dgn)
1120 if(rgSchCb[inst].rgSchInit.usta == FALSE)
1124 memset(&usta, 0, sizeof(RgMngmt));
1126 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1127 usta.t.usta.cmAlarm.category = category;
1128 usta.t.usta.cmAlarm.event = event;
1129 usta.t.usta.cmAlarm.cause = cause;
1132 memcpy(&usta.t.usta.dgn, dgn, sizeof(RgUstaDgn));
1135 rgSchCb[inst].rgSchInit.lmPst.selector =
1136 rgSchCb[inst].genCfg.ustaResp.response.selector;
1137 rgSchCb[inst].rgSchInit.lmPst.prior =
1138 rgSchCb[inst].genCfg.ustaResp.response.prior;
1139 rgSchCb[inst].rgSchInit.lmPst.route =
1140 rgSchCb[inst].genCfg.ustaResp.response.route;
1141 rgSchCb[inst].rgSchInit.lmPst.region =
1142 rgSchCb[inst].genCfg.ustaResp.response.mem.region;
1143 rgSchCb[inst].rgSchInit.lmPst.pool =
1144 rgSchCb[inst].genCfg.ustaResp.response.mem.pool;
1145 usta.hdr.transId = rgSchCb[inst].genCfg.ustaResp.transId;
1147 return (RgMiLrgSchStaInd(&rgSchCb[inst].rgSchInit.lmPst, &usta));
1152 * @brief Scheduler instance timer call back function registered with SSI.
1156 * Function : schActvTmr
1158 * This function is invoked by SSI for every timer activation
1159 * period expiry. Note that SS_MT_TMR flag needs to be enabled for this
1160 * as isntId is needed.As part of SRegTmr call for scheduler instance
1161 * SS_MT_TMR flag needs to be enabled and schActvTmr needs to be given as
1174 S16 schActvTmr(ent, inst)
1179 Inst schInst = (inst - SCH_INST_START);
1181 /* Check if any timer in the scheduler instance has expired */
1182 cmPrcTmr(&rgSchCb[schInst].tmrTqCp,
1183 rgSchCb[schInst].tmrTq, (PFV) rgSCHLmmTmrExpiry);
1187 } /* end of schActvTmr */
1190 /**********************************************************************
1193 **********************************************************************/