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 PUBLIC Void rgSCHCmnInit ARGS((Void));
70 /* forward references */
71 extern int schActvInit(Ent entity, Inst instId, Region region, Reason reason);
73 PRIVATE U16 rgSCHLmmSapCfg ARGS((
80 PRIVATE Void rgSCHLmmShutdown ARGS((
85 PUBLIC 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 U16 rgSCHLmmSapCfg
125 RgCfg *cfg, /* Configuaration information */
126 U8 sapIdx, /* SAP index */
127 Elmnt sapType /* SAP Type */
130 PRIVATE U16 rgSCHLmmSapCfg(dInst, cfg, sapIdx, sapType)
132 RgCfg *cfg; /* Configuaration information */
133 U8 sapIdx; /* SAP index */
134 Elmnt sapType; /* SAP Type */
137 U16 ret = LCM_REASON_NOT_APPL;
138 RgSchLowSapCfgInfo *lowSapCfg = NULLP;
139 RgSchUpSapCfgInfo *upSapCfg = NULLP;
140 Inst inst = (dInst - SCH_INST_START);
144 /* Check if Gen Config has been done */
150 if ((cfg->s.schInstCfg.rgrSap[sapIdx].selector != ODU_SELECTOR_TC) &&
151 (cfg->s.schInstCfg.rgrSap[sapIdx].selector != ODU_SELECTOR_LC))
153 ret = LCM_REASON_INVALID_PAR_VAL;
154 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
155 " Selector value for RGR.");
159 if(rgSchCb[inst].rgrSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
161 rgSchCb[inst].rgrSap[sapIdx].sapSta.sapState = LRG_UNBND;
163 upSapCfg = &rgSchCb[inst].rgrSap[sapIdx].sapCfg;
165 upSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.rgrSap[sapIdx].ent;
166 upSapCfg->sapPst.dstInst = cfg->s.schInstCfg.rgrSap[sapIdx].inst;
167 upSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.rgrSap[sapIdx].procId;
168 upSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
169 upSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
171 upSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
172 upSapCfg->sapPst.region = cfg->s.schInstCfg.rgrSap[sapIdx].mem.region;
173 upSapCfg->sapPst.pool = cfg->s.schInstCfg.rgrSap[sapIdx].mem.pool;
174 upSapCfg->sapPst.selector = cfg->s.schInstCfg.rgrSap[sapIdx].selector;
175 upSapCfg->sapPst.route = cfg->s.schInstCfg.rgrSap[sapIdx].route;
176 upSapCfg->sapPst.intfVer = 0;
177 upSapCfg->sapPst.event = 0;
178 upSapCfg->sapPst.prior = cfg->s.schInstCfg.rgrSap[sapIdx].prior;
179 upSapCfg->suId = cfg->s.schInstCfg.rgrSap[sapIdx].suId;
180 upSapCfg->spId = cfg->s.schInstCfg.rgrSap[sapIdx].spId;
184 if ((cfg->s.schInstCfg.tfuSap[sapIdx].selector != ODU_SELECTOR_TC) &&
185 (cfg->s.schInstCfg.tfuSap[sapIdx].selector != ODU_SELECTOR_LC))
187 ret = LCM_REASON_INVALID_PAR_VAL;
188 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
189 " Selector value for TFU.");
193 if (rgSchCb[inst].tfuSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
195 rgSchCb[inst].tfuSap[sapIdx].sapSta.sapState = LRG_UNBND;
197 /* Initialize the sap timer */
198 cmInitTimers(&(rgSchCb[inst].tfuSap[sapIdx].tmrBlk), 1);
199 lowSapCfg = &rgSchCb[inst].tfuSap[sapIdx].sapCfg;
201 lowSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.tfuSap[sapIdx].ent;
202 lowSapCfg->sapPst.dstInst = cfg->s.schInstCfg.tfuSap[sapIdx].inst;
203 lowSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.tfuSap[sapIdx].procId;
204 lowSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
205 lowSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
207 lowSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
208 lowSapCfg->sapPst.region = cfg->s.schInstCfg.tfuSap[sapIdx].mem.region;
209 lowSapCfg->sapPst.pool = cfg->s.schInstCfg.tfuSap[sapIdx].mem.pool;
210 lowSapCfg->sapPst.selector = cfg->s.schInstCfg.tfuSap[sapIdx].selector;
211 lowSapCfg->sapPst.route = cfg->s.schInstCfg.tfuSap[sapIdx].route;
212 lowSapCfg->sapPst.intfVer = 0;
213 lowSapCfg->sapPst.event = 0;
214 lowSapCfg->sapPst.prior = cfg->s.schInstCfg.tfuSap[sapIdx].prior;
215 lowSapCfg->suId = cfg->s.schInstCfg.tfuSap[sapIdx].suId;
216 lowSapCfg->spId = cfg->s.schInstCfg.tfuSap[sapIdx].spId;
217 cmMemcpy((U8 *)&lowSapCfg->bndTmr,
218 (U8 *)&cfg->s.schInstCfg.tfuSap[sapIdx].bndTmr,
223 if ((cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_LWLC) &&
224 (cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_LC) &&
225 (cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_TC))
227 ret = LCM_REASON_INVALID_PAR_VAL;
228 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
229 " Selector value for RGM.");
233 if (rgSchCb[inst].rgmSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
235 rgSchCb[inst].rgmSap[sapIdx].sapSta.sapState = LRG_UNBND;
237 upSapCfg = &rgSchCb[inst].rgmSap[sapIdx].sapCfg;
238 upSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.rgmSap[sapIdx].ent;
239 upSapCfg->sapPst.dstInst = cfg->s.schInstCfg.rgmSap[sapIdx].inst;
240 upSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.rgmSap[sapIdx].procId;
241 upSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
242 upSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
244 upSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
245 upSapCfg->sapPst.region = cfg->s.schInstCfg.rgmSap[sapIdx].mem.region;
246 upSapCfg->sapPst.pool = cfg->s.schInstCfg.rgmSap[sapIdx].mem.pool;
247 upSapCfg->sapPst.selector = cfg->s.schInstCfg.rgmSap[sapIdx].selector;
248 upSapCfg->sapPst.route = cfg->s.schInstCfg.rgmSap[sapIdx].route;
249 upSapCfg->sapPst.intfVer = 0;
250 upSapCfg->sapPst.event = 0;
251 upSapCfg->sapPst.prior = cfg->s.schInstCfg.rgmSap[sapIdx].prior;
252 upSapCfg->suId = cfg->s.schInstCfg.rgmSap[sapIdx].suId;
253 upSapCfg->spId = cfg->s.schInstCfg.rgmSap[sapIdx].spId;
257 /* would never reach here */
264 /***********************************************************
266 * Func : rgSCHLmmShutdown
269 * Desc : Handles the scheduler instance shutdown request. Calls
270 * rgSCHCfgFreeCellCb(RgSchCellCb*) to handle each cellCb deallocation.
277 * File : rg_sch_lmm.c
279 **********************************************************/
281 PRIVATE Void rgSCHLmmShutdown
286 PRIVATE Void rgSCHLmmShutdown(inst)
290 Inst dInst = inst + SCH_INST_START;
293 CmLList *lnk = NULLP;
294 RgSchCb *instCb = &rgSchCb[inst];
295 RgSchCellCb *cell = NULLP;
296 RgSchL2MeasCb *measCb;
298 RgSchCmnUlCell *cellUl;
299 RgSchClcBoRpt *bo = NULL;
302 TRC2(rgSCHLmmShutdown)
305 for (idx = 0; idx < instCb->numSaps; idx++)
307 /* got the cell break the loop */
308 cell = instCb->rgrSap[idx].cell;
311 /* Free the memory held up by ulAllocInfo */
312 cellUl = RG_SCH_CMN_GET_UL_CELL(cell);
314 for(ulAllocIdx = 0; ulAllocIdx < RGSCH_SF_ALLOC_SIZE; ulAllocIdx++)
316 for(ulAllocIdx = 0; ulAllocIdx < RGSCH_NUM_SUB_FRAMES; ulAllocIdx++)
319 if(cell->sfAllocArr[ulAllocIdx].ulUeInfo.ulAllocInfo != NULLP)
321 /* ccpu00117052 - MOD - Passing double pointer
322 for proper NULLP assignment*/
323 rgSCHUtlFreeSBuf(cell->instIdx,
324 (Data **)(&(cell->sfAllocArr[ulAllocIdx].ulUeInfo.\
326 cellUl->maxAllocPerUlSf * sizeof(RgInfUeUlAlloc));
329 /* Free the memory allocated to measCb */
330 lnk = cell->l2mList.first;
333 measCb = (RgSchL2MeasCb *)lnk->node;
334 cmLListDelFrm(&cell->l2mList, lnk);
336 /* ccpu00117052 - MOD - Passing double pointer
337 for proper NULLP assignment*/
338 rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&measCb,\
339 sizeof(RgSchL2MeasCb));
342 /* Free mem if any present for boLst for common channels */
343 for(idx = 0; idx < RGSCH_MAX_CMN_LC_CB; idx++)
345 lnk = (CmLList *)cell->cmnLcCb[idx].boLst.first;
348 bo = (RgSchClcBoRpt *)(lnk->node);
350 cmLListDelFrm(&cell->cmnLcCb[idx].boLst, &bo->boLstEnt);
351 rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&bo, sizeof(RgSchClcBoRpt));
359 rgSCHLaaDeInitEnbCb(&rgSchCb[inst]);
361 for (idx = 0; idx < rgSchCb[inst].numSaps; idx++)
363 /* Unbind all the TFU SAP */
364 if(rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_WAIT_BNDCFM)
366 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg, LRG_UNBND);
367 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
369 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[idx]);
371 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
373 if(rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND)
375 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg, LRG_UNBND);
376 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
378 /* Free the memory held by the cell associated with this SAP */
379 if (rgSchCb[inst].tfuSap[idx].cell != NULLP)
380 rgSCHCfgFreeCellCb(rgSchCb[inst].tfuSap[idx].cell);
381 rgSchCb[inst].tfuSap[idx].cell = NULLP;
383 /* Free the memory held by the scheduler instance */
384 /* Deallocate RGR saps */
385 SPutSBuf(rgSchCb[inst].rgSchInit.region,
386 rgSchCb[inst].rgSchInit.pool,
387 (Data *)rgSchCb[inst].rgrSap,
388 (sizeof(RgSchUpSapCb) * rgSchCb[inst].numSaps));
389 rgSchCb[inst].rgrSap = NULLP;
390 /* Deallocate RGM saps */
391 SPutSBuf(rgSchCb[inst].rgSchInit.region,
392 rgSchCb[inst].rgSchInit.pool,
393 (Data *)rgSchCb[inst].rgmSap,
394 (sizeof(RgSchUpSapCb) * rgSchCb[inst].numSaps));
395 rgSchCb[inst].rgmSap = NULLP;
397 /* Deallocate TFU saps */
398 SPutSBuf(rgSchCb[inst].rgSchInit.region,
399 rgSchCb[inst].rgSchInit.pool,
400 (Data *)rgSchCb[inst].tfuSap,
401 (sizeof(RgSchLowSapCb) * rgSchCb[inst].numSaps));
402 rgSchCb[inst].tfuSap = NULLP;
404 /* Deallocate bndCfmResponses */
405 SPutSBuf(rgSchCb[inst].rgSchInit.region,
406 rgSchCb[inst].rgSchInit.pool,
407 (Data *)rgSchCb[inst].genCfg.bndCfmResp,
408 (sizeof(RgSchLmResponse) * rgSchCb[inst].numSaps));
409 rgSchCb[inst].genCfg.bndCfmResp = NULLP;
410 /* De-register the Timer Service */
411 (Void) SDeregTmrMt(rgSchCb[inst].rgSchInit.ent, dInst,
412 (S16)rgSchCb[inst].genCfg.tmrRes, schActvTmr);
414 /* call back the task initialization function to intialize
415 * the global rgSchCb[inst] Struct */
416 schActvInit(rgSchCb[inst].rgSchInit.ent, dInst, rgSchCb[inst].rgSchInit.region,
417 rgSchCb[inst].rgSchInit.reason);
419 /* Set Config done in TskInit */
420 rgSchCb[inst].rgSchInit.cfgDone = FALSE;
426 /***********************************************************
428 * Func : rgSCHLmmGenCntrl
431 * Desc : Processes the LM control request for STGEN elmnt.
438 * File : rg_sch_lmm.c
440 **********************************************************/
442 PUBLIC Void rgSCHLmmGenCntrl
449 PUBLIC Void rgSCHLmmGenCntrl(cntrl, cfm, cfmPst)
455 Inst inst = (cfmPst->srcInst - SCH_INST_START); /* Scheduler instance ID */
456 TRC2(rgSCHLmmGenCntrl)
458 cfm->cfm.status = LCM_PRIM_OK;
459 cfm->cfm.reason = LCM_REASON_NOT_APPL;
462 switch(cntrl->t.cntrl.action)
465 /* Action is Enable */
466 switch(cntrl->t.cntrl.subAction)
469 /* Enable Unsolicited Status (alarms) */
470 rgSchCb[inst].rgSchInit.usta = TRUE;
471 /*Store the response and TransId for sending the Alarms */
472 cmMemcpy((U8 *)&rgSchCb[inst].genCfg.ustaResp.response,
473 (U8 *)&cntrl->hdr.response, sizeof(Resp));
474 rgSchCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
477 /* Enable Debug Printing */
479 rgSchCb[inst].rgSchInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
482 #ifdef PHY_ERROR_LOGING
485 rgSchUlAllocCntr.mcs = cntrl->t.cntrl.s.rgSchUlAllocCntrl.mcs;
486 rgSchUlAllocCntr.numOfRb = cntrl->t.cntrl.s.rgSchUlAllocCntrl.numOfRb;
487 rgSchUlAllocCntr.rbStart = cntrl->t.cntrl.s.rgSchUlAllocCntrl.rbStart;
488 rgSchUlAllocCntr.testStart = cntrl->t.cntrl.s.rgSchUlAllocCntrl.testStart;
489 rgSchUlAllocCntr.enaLog = cntrl->t.cntrl.s.rgSchUlAllocCntrl.enaLog;
490 rgSchUlAllocCntr.logTime = cntrl->t.cntrl.s.rgSchUlAllocCntrl.logTime;
491 rgSchUlAllocCntr.crcOk = 0;
492 rgSchUlAllocCntr.crcErr = 0;
493 rgSchUlAllocCntr.numUlPackets = 0;
494 rgSchUlAllocCntr.numPrach = 0;
495 rgSchUlAllocCntr.taZero = 0;
501 cmMemset((U8 *)&hqRetxStats, 0, sizeof(RgSchHqRetxStats));
502 cmMemset((U8 *)&hqFailStats, 0, sizeof(RgSchNackAckStats));
508 cfm->cfm.status = LCM_PRIM_NOK;
509 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
510 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl(): "
511 "invalid subaction=%d", cntrl->t.cntrl.subAction);
516 /* Action is Diable immidiately */
517 switch(cntrl->t.cntrl.subAction)
520 /* Disable Unsolicited Status (alarms) */
521 rgSchCb[inst].rgSchInit.usta = FALSE;
524 /* Disable Debug Printing */
526 rgSchCb[inst].rgSchInit.dbgMask &=\
527 ~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
532 cfm->cfm.status = LCM_PRIM_NOK;
533 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
534 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl():"
535 " invalid subaction=%d", cntrl->t.cntrl.subAction);
540 /* Free all the memory dynamically allocated by MAC */
541 rgSCHLmmShutdown(inst);
544 cfm->cfm.status = LCM_PRIM_NOK;
545 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
546 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl(): invalid"
547 " action=%d", cntrl->t.cntrl.action);
550 RgMiLrgSchCntrlCfm(cfmPst, cfm);
555 /***********************************************************
557 * Func : rgSCHLmmSapCntrl
560 * Desc : Processes the LM control request for STxxxSAP elmnt.
567 * File : rg_sch_lmm.c
569 **********************************************************/
571 PUBLIC Void rgSCHLmmSapCntrl
578 PUBLIC Void rgSCHLmmSapCntrl(cntrl, cfm, cfmPst)
586 /* TODO Pass InstId instead of using InstId from cfmPst */
587 Inst inst = (cfmPst->srcInst - SCH_INST_START); /* Scheduler instance Id */
588 TRC2(rgSCHLmmSapCntrl)
590 /* Only TFU SAP can be controlled by LM */
591 switch(cntrl->hdr.elmId.elmnt)
594 idx = (U8)cntrl->t.cntrl.s.rgSapCntrl.suId;
595 if (idx > LRG_MAX_SAPS_PER_INST)
597 cfm->cfm.status = LCM_PRIM_NOK;
598 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
600 switch(cntrl->t.cntrl.action)
603 /* Bind Enable Request */
604 if ((rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_NOT_CFG) ||
605 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND))
607 cfm->cfm.status = LCM_PRIM_NOK;
608 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
612 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
614 rgSCHLmmStartTmr(inst, RGSCH_BNDREQ_TMR,
615 rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.val,
616 (PTR)&rgSchCb[inst].tfuSap[idx]);
618 /* Change SAP state */
619 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_WAIT_BNDCFM;
620 rgSchCb[inst].tfuSap[idx].numBndRetries++;
621 /* Store the response and TransId for sending
622 * the Control confirm */
623 cmMemcpy((U8 *)&rgSchCb[inst].genCfg.bndCfmResp[idx].response,
624 (U8 *)&cntrl->hdr.response, sizeof(Resp));
625 rgSchCb[inst].genCfg.bndCfmResp[idx].transId =
628 cfm->cfm.status = LCM_PRIM_OK_NDONE;
629 cfm->cfm.reason = LCM_REASON_NOT_APPL;
631 /* Sending Control Confirm before sending Bind
633 RgMiLrgSchCntrlCfm(cfmPst, cfm);
635 rgSCHUtlTfuBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg.suId,
636 rgSchCb[inst].tfuSap[idx].sapCfg.spId);
643 /* Check if the SAP is configured */
644 if( (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_NOT_CFG) ||
645 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_UNBND))
647 cfm->cfm.status = LCM_PRIM_NOK;
648 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
652 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg,
654 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
656 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR,
657 (PTR)&rgSchCb[inst].tfuSap[idx]);
659 /* Change SAP state */
660 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
661 cfm->cfm.status = LCM_PRIM_OK;
662 cfm->cfm.reason = LCM_REASON_NOT_APPL;
666 /* Delete SAP, does initialization of SAP */
667 if ((rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_WAIT_BNDCFM) ||
668 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND))
670 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg,
672 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
674 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR,
675 (PTR)&rgSchCb[inst].tfuSap[idx]);
678 cmMemset((U8 *)&rgSchCb[inst].tfuSap[idx], 0, sizeof(RgSchLowSapCb));
679 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_NOT_CFG;
680 cfm->cfm.status = LCM_PRIM_OK;
681 cfm->cfm.reason = LCM_REASON_NOT_APPL;
684 cfm->cfm.status = LCM_PRIM_NOK;
685 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
686 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
687 "invalid action=%d", cntrl->t.cntrl.action);
692 idx = (U8)cntrl->t.cntrl.s.rgSapCntrl.spId;
693 if (idx > LRG_MAX_SAPS_PER_INST)
695 cfm->cfm.status = LCM_PRIM_NOK;
696 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
698 switch(cntrl->t.cntrl.action)
701 cmMemset((U8 *)&rgSchCb[inst].rgrSap[idx], 0, sizeof(RgSchUpSapCb));
702 rgSchCb[inst].rgrSap[idx].sapSta.sapState = LRG_NOT_CFG;
703 cfm->cfm.status = LCM_PRIM_OK;
704 cfm->cfm.reason = LCM_REASON_NOT_APPL;
707 cfm->cfm.status = LCM_PRIM_NOK;
708 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
709 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
710 "invalid action=%d", cntrl->t.cntrl.action);
715 idx = (U8)cntrl->t.cntrl.s.rgSapCntrl.spId;
716 if (idx > LRG_MAX_SAPS_PER_INST)
718 cfm->cfm.status = LCM_PRIM_NOK;
719 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
721 switch(cntrl->t.cntrl.action)
724 cmMemset((U8 *)&rgSchCb[inst].rgmSap[idx], 0, sizeof(RgSchUpSapCb));
725 rgSchCb[inst].rgmSap[idx].sapSta.sapState = LRG_NOT_CFG;
726 cfm->cfm.status = LCM_PRIM_OK;
727 cfm->cfm.reason = LCM_REASON_NOT_APPL;
730 cfm->cfm.status = LCM_PRIM_NOK;
731 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
732 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
733 "invalid action=%d", cntrl->t.cntrl.action);
739 /* Would never come here. */
742 RgMiLrgSchCntrlCfm(cfmPst, cfm);
747 /***********************************************************
749 * Func : SchFillCfmPst
752 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
753 * and the cfm->hdr.response.
760 * File : rg_sch_lmm.c
762 **********************************************************/
764 PUBLIC Void SchFillCfmPst
771 PUBLIC Void SchFillCfmPst(reqPst, cfmPst, cfm)
781 inst = (reqPst->dstInst - SCH_INST_START);
783 cfmPst->srcEnt = ENTRG;
784 cfmPst->srcInst = (Inst) 1;
785 cfmPst->srcProcId = rgSchCb[inst].rgSchInit.procId;
786 cfmPst->dstEnt = ENTRG;
787 cfmPst->dstInst = (Inst) 0;
788 cfmPst->dstProcId = reqPst->srcProcId;
790 cfmPst->selector = cfm->hdr.response.selector;
791 cfmPst->region = cfm->hdr.response.mem.region;
792 cfmPst->pool = cfm->hdr.response.mem.pool;
799 * @brief Timer start handler.
803 * Function : rgSCHLmmStartTmr
805 * This function based on the input parameters starts the timer for
806 * "tmrVal" duration. As of now scheduler instance uses the timer
807 * functionality for BndReq only. Hence there is no conditional
808 * code based on "tmrEvnt".
810 * @param[in] S16 tmrEvnt, the Timer Event
811 * @param[in] U32 tmrVal, the Wait Time
812 * @param[in] PTR cb, Entry for which Timer expired
817 PUBLIC S16 rgSCHLmmStartTmr
820 S16 tmrEvnt, /* Timer Event */
821 U32 tmrVal, /* Wait Time */
822 PTR cb /* Entry for which Timer Expired */
825 PUBLIC S16 rgSCHLmmStartTmr(inst, tmrEvnt, tmrVal, cb)
826 Inst inst; /* scheduler instance ID */
827 S16 tmrEvnt; /* Timer Event */
828 U32 tmrVal; /* Wait Time */
829 PTR cb; /* Entry for which Timer Expired */
833 /* Inst dInst = inst + SCH_INST_START; */
835 TRC2(rgSCHLmmStartTmr)
839 /* Initialize the arg structure */
840 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
842 arg.tqCp = &rgSchCb[inst].tmrTqCp;
843 arg.tq = rgSchCb[inst].tmrTq;
844 arg.timers = &((RgSchLowSapCb *)cb)->tmrBlk;
847 arg.max = RGSCH_MAX_TIMER;
848 arg.evnt = RGSCH_BNDREQ_TMR;
857 * @brief Timer stop handler.
861 * Function : rgSCHLmmStopTmr
863 * This function based on the input parameters stops the timer for
864 * "tmrEvnt". As of now Scheduler instance uses the timer functionality for
865 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
866 * Once the bind happens and this timer is stopped, the timer functionality
867 * is deregistered with SSI. As there is no further use of timer processing.
869 * @param[in] S16 tmrEvnt, the Timer Event
870 * @param[in] PTR cb, Entry for which Timer expired
876 PUBLIC S16 rgSCHLmmStopTmr
878 Inst inst, /* Scheduler instance */
879 S16 tmrEvnt, /* Timer Event */
880 PTR cb /* Entry for which Timer Expired */
883 PUBLIC S16 rgSCHLmmStopTmr(inst, tmrEvnt, cb)
884 Inst inst; /* Scheduler instance */
885 S16 tmrEvnt; /* Timer Event */
886 PTR cb; /* Entry for which Timer Expired */
893 TRC2(rgSCHLmmStopTmr)
897 for(i=0;i<RGSCH_MAX_TIMER;i++)
899 /* Search for the Timer Blocks */
900 if(((RgSchLowSapCb *)cb)->tmrBlk.tmrEvnt == tmrEvnt)
902 /* Initialize the arg structure */
903 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
905 arg.tqCp = &rgSchCb[inst].tmrTqCp;
906 arg.tq = rgSchCb[inst].tmrTq;
907 arg.timers = &(((RgSchLowSapCb *)cb)->tmrBlk);
909 arg.max = RGSCH_MAX_TIMER;
926 * @brief Timer Expiry handler.
930 * Function : rgSCHLmmTmrExpiry
932 * This is a callback function used as an input parameter to cmPrcTmr()
933 * to check expiry of any timer. In this function, we are only concerned
934 * about tmrEvnt=Bind timer.
936 * @param[in] PTR cb, Entry for which Timer expired
937 * @param[in] S16 tmrEvnt, the Timer Event
942 PUBLIC S16 rgSCHLmmTmrExpiry
944 PTR cb, /* Pointer to timer control block */
945 S16 tmrEvnt /* Timer Event */
948 PUBLIC S16 rgSCHLmmTmrExpiry(cb,tmrEvnt)
949 PTR cb; /* Pointer to timer control block */
950 S16 tmrEvnt; /* Timer Event */
954 RgSchLowSapCb *tfuSap = (RgSchLowSapCb *)cb;
956 Inst inst = tfuSap->cell->instIdx;
958 TRC2(rgSCHLmmTmrExpiry)
963 case RGSCH_BNDREQ_TMR:
964 tfuSap->numBndRetries++;
965 if(tfuSap->numBndRetries > RGSCH_MAX_BNDRETRY)
967 rgSCHLmmStaInd((U8)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
968 (U16)LCM_CATEGORY_INTERFACE, (U16)LCM_EVENT_BND_FAIL,
969 (U16)LCM_CAUSE_TMR_EXPIRED, (RgUstaDgn *)NULLP);
973 /* Restart the bind timer */
974 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
976 ret = rgSCHLmmStartTmr((U8)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
978 (U32)tfuSap->sapCfg.bndTmr.val, cb);
981 /* Send bind request */
982 rgSCHUtlTfuBndReq((U8)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
983 tfuSap->sapCfg.suId, tfuSap->sapCfg.spId);
987 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmTmrExpiry(): Invalid"
988 " tmrEvnt=%d", tmrEvnt);
997 * @brief Layer Manager Control Confirm generation handler
998 * for Bind Confirm reception at TFU interface.
999 * RgLiTfuBndCfm() forwards the confirmation to this
1000 * function. All SAP state related handling is restricted
1001 * to LMM modules, hence the cfm forwarding.
1005 * Function : rgSCHLmmBndCfm
1007 * This API is used by the LIM module of MAC to forward
1008 * the Bind Confirm it receives over the TFU interface.
1010 * @param[in] Pst *pst, Post Structure
1011 * @param[in] SuId suId, Service user ID
1012 * @param[in] U8 status, Status
1017 PUBLIC S16 rgSCHLmmBndCfm
1019 Pst *pst, /* Post Structure */
1020 SuId suId, /* Service user ID */
1021 U8 status /* Status */
1024 PUBLIC S16 rgSCHLmmBndCfm(pst,suId,status)
1025 Pst *pst; /* Post Structure */
1026 SuId suId; /* Service user Id */
1027 U8 status; /* Status */
1033 Inst inst = (pst->dstInst - SCH_INST_START); /* scheduler instance */
1035 TRC2(rgSCHLmmBndCfm)
1038 /* check the SAP State */
1039 switch(rgSchCb[inst].tfuSap[suId].sapSta.sapState)
1041 case LRG_WAIT_BNDCFM:
1044 /* SAP is already bound */
1050 cfmPst = rgSchCb[inst].rgSchInit.lmPst;
1051 cfmPst.selector = rgSchCb[inst].genCfg.bndCfmResp[suId].response.selector;
1052 cfmPst.prior = rgSchCb[inst].genCfg.bndCfmResp[suId].response.prior;
1053 cfmPst.route = rgSchCb[inst].genCfg.bndCfmResp[suId].response.route;
1054 cfmPst.region = rgSchCb[inst].genCfg.bndCfmResp[suId].response.mem.region;
1055 cfmPst.pool = rgSchCb[inst].genCfg.bndCfmResp[suId].response.mem.pool;
1057 cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
1061 case CM_BND_OK: /* status is OK */
1062 /* Change SAP state to Bound */
1063 rgSchCb[inst].tfuSap[suId].sapSta.sapState = LRG_BND;
1064 if (rgSchCb[inst].tfuSap[suId].sapCfg.bndTmr.enb == TRUE)
1066 ret = rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[suId]);
1068 /* Send Control Confirm with status as OK to Layer Manager */
1069 cntrlCfm.cfm.status = LCM_PRIM_OK;
1070 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1071 /* Sending Status Indication to Layer Manager */
1072 rgSCHLmmStaInd((U8)(rgSchCb[inst].tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
1073 LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_OK,
1074 LCM_CAUSE_LYR_SPECIFIC, (RgUstaDgn *)NULLP);
1078 /* Change SAP state to UnBound */
1079 rgSchCb[inst].tfuSap[suId].sapSta.sapState = LRG_UNBND;
1080 if (rgSchCb[inst].tfuSap[suId].sapCfg.bndTmr.enb == TRUE)
1082 ret = rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[suId]);
1084 /* Send Control Confirm with status as NOK to Layer Manager */
1085 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1086 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1089 rgSchCb[inst].tfuSap[suId].numBndRetries = 0;
1090 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1091 cntrlCfm.hdr.transId = rgSchCb[inst].genCfg.bndCfmResp[suId].transId;
1093 ret = RgMiLrgSchCntrlCfm(&cfmPst, &cntrlCfm);
1099 * @brief Layer Manager Unsolicited Status Indication generation.
1103 * Function : rgSCHLmmStaInd
1105 * This API is used by the other modules of MAC to send a unsolicited
1106 * status indication to the Layer Manager.
1108 * @param[in] U16 category, the Alarm category
1109 * @param[in] U16 event, the Alarm event
1110 * @param[in] U16 cause, the cause of the Alarm
1111 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1116 PUBLIC S16 rgSCHLmmStaInd
1125 PUBLIC S16 rgSCHLmmStaInd(inst, category, event, cause, dgn)
1135 TRC2(rgSCHLmmStaInd)
1137 if(rgSchCb[inst].rgSchInit.usta == FALSE)
1142 cmMemset((U8 *)&usta, 0, sizeof(RgMngmt));
1144 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1145 usta.t.usta.cmAlarm.category = category;
1146 usta.t.usta.cmAlarm.event = event;
1147 usta.t.usta.cmAlarm.cause = cause;
1150 cmMemcpy((U8 *)&usta.t.usta.dgn, (U8 *)dgn, sizeof(RgUstaDgn));
1153 rgSchCb[inst].rgSchInit.lmPst.selector =
1154 rgSchCb[inst].genCfg.ustaResp.response.selector;
1155 rgSchCb[inst].rgSchInit.lmPst.prior =
1156 rgSchCb[inst].genCfg.ustaResp.response.prior;
1157 rgSchCb[inst].rgSchInit.lmPst.route =
1158 rgSchCb[inst].genCfg.ustaResp.response.route;
1159 rgSchCb[inst].rgSchInit.lmPst.region =
1160 rgSchCb[inst].genCfg.ustaResp.response.mem.region;
1161 rgSchCb[inst].rgSchInit.lmPst.pool =
1162 rgSchCb[inst].genCfg.ustaResp.response.mem.pool;
1163 usta.hdr.transId = rgSchCb[inst].genCfg.ustaResp.transId;
1165 return (RgMiLrgSchStaInd(&rgSchCb[inst].rgSchInit.lmPst, &usta));
1170 * @brief Scheduler instance timer call back function registered with SSI.
1174 * Function : schActvTmr
1176 * This function is invoked by SSI for every timer activation
1177 * period expiry. Note that SS_MT_TMR flag needs to be enabled for this
1178 * as isntId is needed.As part of SRegTmr call for scheduler instance
1179 * SS_MT_TMR flag needs to be enabled and schActvTmr needs to be given as
1186 PUBLIC S16 schActvTmr
1192 PUBLIC S16 schActvTmr(ent, inst)
1197 Inst schInst = (inst - SCH_INST_START);
1200 /* Check if any timer in the scheduler instance has expired */
1201 cmPrcTmr(&rgSchCb[schInst].tmrTqCp,
1202 rgSchCb[schInst].tmrTq, (PFV) rgSCHLmmTmrExpiry);
1206 } /* end of schActvTmr */
1209 /**********************************************************************
1212 **********************************************************************/