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 "envopt.h" /* environment options */
43 #include "envdep.h" /* environment dependent */
44 #include "envind.h" /* environment independent */
45 #include "gen.h" /* general */
46 #include "ssi.h" /* system services */
47 #include "cm_tkns.h" /* Common Token Defines */
48 #include "cm_llist.h" /* Common Link List Defines */
49 #include "cm_hash.h" /* Common Hash List Defines */
50 #include "cm_mblk.h" /* common memory link list library */
51 #include "cm_lte.h" /* Common LTE Defines */
52 #include "rg_env.h" /* MAC Environment Defines */
53 #include "rgr.h" /* RGR Interface defines */
54 #include "tfu.h" /* RGU Interface defines */
55 #include "lrg.h" /* LRG Interface defines */
56 #include "rgm.h" /* RGM Interface defines */
57 #include "rg_sch.h" /* Scheduler defines */
58 #include "rg_sch_inf.h" /* Scheduler defines */
59 #include "rg_sch_err.h" /* MAC error defines */
61 #include "rg_sch_cmn.h" /* typedefs for Scheduler */
63 #include "rl_interface.h"
64 #include "rl_common.h"
66 /* header/extern include files (.x) */
67 #include "gen.x" /* general */
68 #include "ssi.x" /* system services */
69 #include "cm5.x" /* system services */
70 #include "cm_tkns.x" /* Common Token Definitions */
71 #include "cm_llist.x" /* Common Link List Definitions */
72 #include "cm_lib.x" /* Common Library Definitions */
73 #include "cm_hash.x" /* Common Hash List Definitions */
74 #include "cm_mblk.x" /* common memory link list library */
75 #include "cm_lte.x" /* Common LTE Defines */
76 #include "rgr.x" /* RGR Interface includes */
77 #include "rgm.x" /* RGM Interface includes */
78 #include "tfu.x" /* RGU Interface includes */
79 #include "lrg.x" /* LRG Interface includes */
80 #include "rg_sch_inf.x" /* Scheduler defines */
81 #include "rg_sch.x" /* Scheduler includes */
83 #include "rg_sch_cmn.x" /* typedefs for Scheduler */
86 PUBLIC Void rgSCHCmnInit ARGS((Void));
88 /* forward references */
91 PRIVATE U16 rgSCHLmmSapCfg ARGS((
98 PRIVATE Void rgSCHLmmShutdown ARGS((
103 PUBLIC void printSchCellInfo(void)
107 for (idx = 0; idx < rgSchCb[inst].numSaps; idx++)
109 /* Unbind all the TFU SAP */
110 /* Free the memory held by the cell associated
112 if (rgSchCb[inst].tfuSap[idx].cell != NULLP)
114 RLOG1(L_INFO,"CELL %d\n", idx);
115 RLOG1(L_INFO,"NUM UEs :%d\n",rgSchCb[inst].tfuSap[idx].cell->ueLst.nmbEnt);
121 * @brief SAP Configuration Handler.
125 * Function : rgSCHLmmSapCfg
127 * This function in called by HandleSchGenCfgReq(). It handles the
128 * interface SAP configuration of the scheduler instance. It
129 * initializes the sapState to LRG_UNBND. Returns
130 * reason for success/failure of this function.
132 * @param[in] RgCfg *cfg, the Configuaration information
134 * -# LCM_REASON_GENCFG_NOT_DONE
135 * -# LCM_REASON_INVALID_SAP
136 * -# LCM_REASON_NOT_APPL
140 PRIVATE U16 rgSCHLmmSapCfg
143 RgCfg *cfg, /* Configuaration information */
144 U8 sapIdx, /* SAP index */
145 Elmnt sapType /* SAP Type */
148 PRIVATE U16 rgSCHLmmSapCfg(dInst, cfg, sapIdx, sapType)
150 RgCfg *cfg; /* Configuaration information */
151 U8 sapIdx; /* SAP index */
152 Elmnt sapType; /* SAP Type */
155 U16 ret = LCM_REASON_NOT_APPL;
156 RgSchLowSapCfgInfo *lowSapCfg = NULLP;
157 RgSchUpSapCfgInfo *upSapCfg = NULLP;
158 Inst inst = (dInst - SCH_INST_START);
162 /* Check if Gen Config has been done */
168 if ((cfg->s.schInstCfg.rgrSap[sapIdx].selector != RGR_SEL_TC) &&
169 (cfg->s.schInstCfg.rgrSap[sapIdx].selector != RGR_SEL_LC))
171 ret = LCM_REASON_INVALID_PAR_VAL;
172 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
173 " Selector value for RGR.");
177 if(rgSchCb[inst].rgrSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
179 rgSchCb[inst].rgrSap[sapIdx].sapSta.sapState = LRG_UNBND;
181 upSapCfg = &rgSchCb[inst].rgrSap[sapIdx].sapCfg;
183 upSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.rgrSap[sapIdx].ent;
184 upSapCfg->sapPst.dstInst = cfg->s.schInstCfg.rgrSap[sapIdx].inst;
185 upSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.rgrSap[sapIdx].procId;
186 upSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
187 upSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
189 upSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
190 upSapCfg->sapPst.region = cfg->s.schInstCfg.rgrSap[sapIdx].mem.region;
191 upSapCfg->sapPst.pool = cfg->s.schInstCfg.rgrSap[sapIdx].mem.pool;
192 upSapCfg->sapPst.selector = cfg->s.schInstCfg.rgrSap[sapIdx].selector;
193 upSapCfg->sapPst.route = cfg->s.schInstCfg.rgrSap[sapIdx].route;
194 upSapCfg->sapPst.intfVer = 0;
195 upSapCfg->sapPst.event = 0;
196 upSapCfg->sapPst.prior = cfg->s.schInstCfg.rgrSap[sapIdx].prior;
197 upSapCfg->suId = cfg->s.schInstCfg.rgrSap[sapIdx].suId;
198 upSapCfg->spId = cfg->s.schInstCfg.rgrSap[sapIdx].spId;
202 if ((cfg->s.schInstCfg.tfuSap[sapIdx].selector != TFU_SEL_TC) &&
203 (cfg->s.schInstCfg.tfuSap[sapIdx].selector != TFU_SEL_LC))
205 ret = LCM_REASON_INVALID_PAR_VAL;
206 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
207 " Selector value for TFU.");
211 if (rgSchCb[inst].tfuSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
213 rgSchCb[inst].tfuSap[sapIdx].sapSta.sapState = LRG_UNBND;
215 /* Initialize the sap timer */
216 cmInitTimers(&(rgSchCb[inst].tfuSap[sapIdx].tmrBlk), 1);
217 lowSapCfg = &rgSchCb[inst].tfuSap[sapIdx].sapCfg;
219 lowSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.tfuSap[sapIdx].ent;
220 lowSapCfg->sapPst.dstInst = cfg->s.schInstCfg.tfuSap[sapIdx].inst;
221 lowSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.tfuSap[sapIdx].procId;
222 lowSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
223 lowSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
225 lowSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
226 lowSapCfg->sapPst.region = cfg->s.schInstCfg.tfuSap[sapIdx].mem.region;
227 lowSapCfg->sapPst.pool = cfg->s.schInstCfg.tfuSap[sapIdx].mem.pool;
228 lowSapCfg->sapPst.selector = cfg->s.schInstCfg.tfuSap[sapIdx].selector;
229 lowSapCfg->sapPst.route = cfg->s.schInstCfg.tfuSap[sapIdx].route;
230 lowSapCfg->sapPst.intfVer = 0;
231 lowSapCfg->sapPst.event = 0;
232 lowSapCfg->sapPst.prior = cfg->s.schInstCfg.tfuSap[sapIdx].prior;
233 lowSapCfg->suId = cfg->s.schInstCfg.tfuSap[sapIdx].suId;
234 lowSapCfg->spId = cfg->s.schInstCfg.tfuSap[sapIdx].spId;
235 cmMemcpy((U8 *)&lowSapCfg->bndTmr,
236 (U8 *)&cfg->s.schInstCfg.tfuSap[sapIdx].bndTmr,
241 if ((cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_LWLC) &&
242 (cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_LC) &&
243 (cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_TC))
245 ret = LCM_REASON_INVALID_PAR_VAL;
246 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
247 " Selector value for RGM.");
251 if (rgSchCb[inst].rgmSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
253 rgSchCb[inst].rgmSap[sapIdx].sapSta.sapState = LRG_UNBND;
255 upSapCfg = &rgSchCb[inst].rgmSap[sapIdx].sapCfg;
256 upSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.rgmSap[sapIdx].ent;
257 upSapCfg->sapPst.dstInst = cfg->s.schInstCfg.rgmSap[sapIdx].inst;
258 upSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.rgmSap[sapIdx].procId;
259 upSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
260 upSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
262 upSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
263 upSapCfg->sapPst.region = cfg->s.schInstCfg.rgmSap[sapIdx].mem.region;
264 upSapCfg->sapPst.pool = cfg->s.schInstCfg.rgmSap[sapIdx].mem.pool;
265 upSapCfg->sapPst.selector = cfg->s.schInstCfg.rgmSap[sapIdx].selector;
266 upSapCfg->sapPst.route = cfg->s.schInstCfg.rgmSap[sapIdx].route;
267 upSapCfg->sapPst.intfVer = 0;
268 upSapCfg->sapPst.event = 0;
269 upSapCfg->sapPst.prior = cfg->s.schInstCfg.rgmSap[sapIdx].prior;
270 upSapCfg->suId = cfg->s.schInstCfg.rgmSap[sapIdx].suId;
271 upSapCfg->spId = cfg->s.schInstCfg.rgmSap[sapIdx].spId;
275 /* would never reach here */
282 /***********************************************************
284 * Func : rgSCHLmmShutdown
287 * Desc : Handles the scheduler instance shutdown request. Calls
288 * rgSCHCfgFreeCellCb(RgSchCellCb*) to handle each cellCb deallocation.
295 * File : rg_sch_lmm.c
297 **********************************************************/
299 PRIVATE Void rgSCHLmmShutdown
304 PRIVATE Void rgSCHLmmShutdown(inst)
308 Inst dInst = inst + SCH_INST_START;
311 CmLList *lnk = NULLP;
312 RgSchCb *instCb = &rgSchCb[inst];
313 RgSchCellCb *cell = NULLP;
314 RgSchL2MeasCb *measCb;
316 RgSchCmnUlCell *cellUl;
317 RgSchClcBoRpt *bo = NULL;
320 TRC2(rgSCHLmmShutdown)
323 for (idx = 0; idx < instCb->numSaps; idx++)
325 /* got the cell break the loop */
326 cell = instCb->rgrSap[idx].cell;
329 /* Free the memory held up by ulAllocInfo */
330 cellUl = RG_SCH_CMN_GET_UL_CELL(cell);
332 for(ulAllocIdx = 0; ulAllocIdx < RGSCH_SF_ALLOC_SIZE; ulAllocIdx++)
334 for(ulAllocIdx = 0; ulAllocIdx < RGSCH_NUM_SUB_FRAMES; ulAllocIdx++)
337 if(cell->sfAllocArr[ulAllocIdx].ulUeInfo.ulAllocInfo != NULLP)
339 /* ccpu00117052 - MOD - Passing double pointer
340 for proper NULLP assignment*/
341 rgSCHUtlFreeSBuf(cell->instIdx,
342 (Data **)(&(cell->sfAllocArr[ulAllocIdx].ulUeInfo.\
344 cellUl->maxAllocPerUlSf * sizeof(RgInfUeUlAlloc));
347 /* Free the memory allocated to measCb */
348 lnk = cell->l2mList.first;
351 measCb = (RgSchL2MeasCb *)lnk->node;
352 cmLListDelFrm(&cell->l2mList, lnk);
354 /* ccpu00117052 - MOD - Passing double pointer
355 for proper NULLP assignment*/
356 rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&measCb,\
357 sizeof(RgSchL2MeasCb));
360 /* Free mem if any present for boLst for common channels */
361 for(idx = 0; idx < RGSCH_MAX_CMN_LC_CB; idx++)
363 lnk = (CmLList *)cell->cmnLcCb[idx].boLst.first;
366 bo = (RgSchClcBoRpt *)(lnk->node);
368 cmLListDelFrm(&cell->cmnLcCb[idx].boLst, &bo->boLstEnt);
369 rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&bo, sizeof(RgSchClcBoRpt));
377 rgSCHLaaDeInitEnbCb(&rgSchCb[inst]);
379 for (idx = 0; idx < rgSchCb[inst].numSaps; idx++)
381 /* Unbind all the TFU SAP */
382 if(rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_WAIT_BNDCFM)
384 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg, LRG_UNBND);
385 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
387 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[idx]);
389 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
391 if(rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND)
393 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg, LRG_UNBND);
394 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
396 /* Free the memory held by the cell associated with this SAP */
397 if (rgSchCb[inst].tfuSap[idx].cell != NULLP)
398 rgSCHCfgFreeCellCb(rgSchCb[inst].tfuSap[idx].cell);
399 rgSchCb[inst].tfuSap[idx].cell = NULLP;
401 /* Free the memory held by the scheduler instance */
402 /* Deallocate RGR saps */
403 SPutSBuf(rgSchCb[inst].rgSchInit.region,
404 rgSchCb[inst].rgSchInit.pool,
405 (Data *)rgSchCb[inst].rgrSap,
406 (sizeof(RgSchUpSapCb) * rgSchCb[inst].numSaps));
407 rgSchCb[inst].rgrSap = NULLP;
408 /* Deallocate RGM saps */
409 SPutSBuf(rgSchCb[inst].rgSchInit.region,
410 rgSchCb[inst].rgSchInit.pool,
411 (Data *)rgSchCb[inst].rgmSap,
412 (sizeof(RgSchUpSapCb) * rgSchCb[inst].numSaps));
413 rgSchCb[inst].rgmSap = NULLP;
415 /* Deallocate TFU saps */
416 SPutSBuf(rgSchCb[inst].rgSchInit.region,
417 rgSchCb[inst].rgSchInit.pool,
418 (Data *)rgSchCb[inst].tfuSap,
419 (sizeof(RgSchLowSapCb) * rgSchCb[inst].numSaps));
420 rgSchCb[inst].tfuSap = NULLP;
422 /* Deallocate bndCfmResponses */
423 SPutSBuf(rgSchCb[inst].rgSchInit.region,
424 rgSchCb[inst].rgSchInit.pool,
425 (Data *)rgSchCb[inst].genCfg.bndCfmResp,
426 (sizeof(RgSchLmResponse) * rgSchCb[inst].numSaps));
427 rgSchCb[inst].genCfg.bndCfmResp = NULLP;
428 /* De-register the Timer Service */
429 (Void) SDeregTmrMt(rgSchCb[inst].rgSchInit.ent, dInst,
430 (S16)rgSchCb[inst].genCfg.tmrRes, schActvTmr);
432 /* call back the task initialization function to intialize
433 * the global rgSchCb[inst] Struct */
434 schActvInit(rgSchCb[inst].rgSchInit.ent, dInst, rgSchCb[inst].rgSchInit.region,
435 rgSchCb[inst].rgSchInit.reason);
437 /* Set Config done in TskInit */
438 rgSchCb[inst].rgSchInit.cfgDone = FALSE;
444 /***********************************************************
446 * Func : rgSCHLmmGenCntrl
449 * Desc : Processes the LM control request for STGEN elmnt.
456 * File : rg_sch_lmm.c
458 **********************************************************/
460 PUBLIC Void rgSCHLmmGenCntrl
467 PUBLIC Void rgSCHLmmGenCntrl(cntrl, cfm, cfmPst)
473 Inst inst = (cfmPst->srcInst - SCH_INST_START); /* Scheduler instance ID */
474 TRC2(rgSCHLmmGenCntrl)
476 cfm->cfm.status = LCM_PRIM_OK;
477 cfm->cfm.reason = LCM_REASON_NOT_APPL;
480 switch(cntrl->t.cntrl.action)
483 /* Action is Enable */
484 switch(cntrl->t.cntrl.subAction)
487 /* Enable Unsolicited Status (alarms) */
488 rgSchCb[inst].rgSchInit.usta = TRUE;
489 /*Store the response and TransId for sending the Alarms */
490 cmMemcpy((U8 *)&rgSchCb[inst].genCfg.ustaResp.response,
491 (U8 *)&cntrl->hdr.response, sizeof(Resp));
492 rgSchCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
495 /* Enable Debug Printing */
497 rgSchCb[inst].rgSchInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
500 #ifdef PHY_ERROR_LOGING
503 rgSchUlAllocCntr.mcs = cntrl->t.cntrl.s.rgSchUlAllocCntrl.mcs;
504 rgSchUlAllocCntr.numOfRb = cntrl->t.cntrl.s.rgSchUlAllocCntrl.numOfRb;
505 rgSchUlAllocCntr.rbStart = cntrl->t.cntrl.s.rgSchUlAllocCntrl.rbStart;
506 rgSchUlAllocCntr.testStart = cntrl->t.cntrl.s.rgSchUlAllocCntrl.testStart;
507 rgSchUlAllocCntr.enaLog = cntrl->t.cntrl.s.rgSchUlAllocCntrl.enaLog;
508 rgSchUlAllocCntr.logTime = cntrl->t.cntrl.s.rgSchUlAllocCntrl.logTime;
509 rgSchUlAllocCntr.crcOk = 0;
510 rgSchUlAllocCntr.crcErr = 0;
511 rgSchUlAllocCntr.numUlPackets = 0;
512 rgSchUlAllocCntr.numPrach = 0;
513 rgSchUlAllocCntr.taZero = 0;
519 cmMemset((U8 *)&hqRetxStats, 0, sizeof(RgSchHqRetxStats));
520 cmMemset((U8 *)&hqFailStats, 0, sizeof(RgSchNackAckStats));
526 cfm->cfm.status = LCM_PRIM_NOK;
527 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
528 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl(): "
529 "invalid subaction=%d", cntrl->t.cntrl.subAction);
534 /* Action is Diable immidiately */
535 switch(cntrl->t.cntrl.subAction)
538 /* Disable Unsolicited Status (alarms) */
539 rgSchCb[inst].rgSchInit.usta = FALSE;
542 /* Disable Debug Printing */
544 rgSchCb[inst].rgSchInit.dbgMask &=\
545 ~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
550 cfm->cfm.status = LCM_PRIM_NOK;
551 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
552 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl():"
553 " invalid subaction=%d", cntrl->t.cntrl.subAction);
558 /* Free all the memory dynamically allocated by MAC */
559 rgSCHLmmShutdown(inst);
562 cfm->cfm.status = LCM_PRIM_NOK;
563 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
564 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl(): invalid"
565 " action=%d", cntrl->t.cntrl.action);
568 RgMiLrgSchCntrlCfm(cfmPst, cfm);
573 /***********************************************************
575 * Func : rgSCHLmmSapCntrl
578 * Desc : Processes the LM control request for STxxxSAP elmnt.
585 * File : rg_sch_lmm.c
587 **********************************************************/
589 PUBLIC Void rgSCHLmmSapCntrl
596 PUBLIC Void rgSCHLmmSapCntrl(cntrl, cfm, cfmPst)
604 /* TODO Pass InstId instead of using InstId from cfmPst */
605 Inst inst = (cfmPst->srcInst - SCH_INST_START); /* Scheduler instance Id */
606 TRC2(rgSCHLmmSapCntrl)
608 /* Only TFU SAP can be controlled by LM */
609 switch(cntrl->hdr.elmId.elmnt)
612 idx = (U8)cntrl->t.cntrl.s.rgSapCntrl.suId;
613 if (idx > LRG_MAX_SAPS_PER_INST)
615 cfm->cfm.status = LCM_PRIM_NOK;
616 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
618 switch(cntrl->t.cntrl.action)
621 /* Bind Enable Request */
622 if ((rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_NOT_CFG) ||
623 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND))
625 cfm->cfm.status = LCM_PRIM_NOK;
626 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
630 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
632 rgSCHLmmStartTmr(inst, RGSCH_BNDREQ_TMR,
633 rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.val,
634 (PTR)&rgSchCb[inst].tfuSap[idx]);
636 /* Change SAP state */
637 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_WAIT_BNDCFM;
638 rgSchCb[inst].tfuSap[idx].numBndRetries++;
639 /* Store the response and TransId for sending
640 * the Control confirm */
641 cmMemcpy((U8 *)&rgSchCb[inst].genCfg.bndCfmResp[idx].response,
642 (U8 *)&cntrl->hdr.response, sizeof(Resp));
643 rgSchCb[inst].genCfg.bndCfmResp[idx].transId =
646 cfm->cfm.status = LCM_PRIM_OK_NDONE;
647 cfm->cfm.reason = LCM_REASON_NOT_APPL;
649 /* Sending Control Confirm before sending Bind
651 RgMiLrgSchCntrlCfm(cfmPst, cfm);
653 rgSCHUtlTfuBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg.suId,
654 rgSchCb[inst].tfuSap[idx].sapCfg.spId);
661 /* Check if the SAP is configured */
662 if( (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_NOT_CFG) ||
663 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_UNBND))
665 cfm->cfm.status = LCM_PRIM_NOK;
666 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
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]);
677 /* Change SAP state */
678 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
679 cfm->cfm.status = LCM_PRIM_OK;
680 cfm->cfm.reason = LCM_REASON_NOT_APPL;
684 /* Delete SAP, does initialization of SAP */
685 if ((rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_WAIT_BNDCFM) ||
686 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND))
688 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg,
690 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
692 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR,
693 (PTR)&rgSchCb[inst].tfuSap[idx]);
696 cmMemset((U8 *)&rgSchCb[inst].tfuSap[idx], 0, sizeof(RgSchLowSapCb));
697 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_NOT_CFG;
698 cfm->cfm.status = LCM_PRIM_OK;
699 cfm->cfm.reason = LCM_REASON_NOT_APPL;
702 cfm->cfm.status = LCM_PRIM_NOK;
703 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
704 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
705 "invalid action=%d", cntrl->t.cntrl.action);
710 idx = (U8)cntrl->t.cntrl.s.rgSapCntrl.spId;
711 if (idx > LRG_MAX_SAPS_PER_INST)
713 cfm->cfm.status = LCM_PRIM_NOK;
714 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
716 switch(cntrl->t.cntrl.action)
719 cmMemset((U8 *)&rgSchCb[inst].rgrSap[idx], 0, sizeof(RgSchUpSapCb));
720 rgSchCb[inst].rgrSap[idx].sapSta.sapState = LRG_NOT_CFG;
721 cfm->cfm.status = LCM_PRIM_OK;
722 cfm->cfm.reason = LCM_REASON_NOT_APPL;
725 cfm->cfm.status = LCM_PRIM_NOK;
726 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
727 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
728 "invalid action=%d", cntrl->t.cntrl.action);
733 idx = (U8)cntrl->t.cntrl.s.rgSapCntrl.spId;
734 if (idx > LRG_MAX_SAPS_PER_INST)
736 cfm->cfm.status = LCM_PRIM_NOK;
737 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
739 switch(cntrl->t.cntrl.action)
742 cmMemset((U8 *)&rgSchCb[inst].rgmSap[idx], 0, sizeof(RgSchUpSapCb));
743 rgSchCb[inst].rgmSap[idx].sapSta.sapState = LRG_NOT_CFG;
744 cfm->cfm.status = LCM_PRIM_OK;
745 cfm->cfm.reason = LCM_REASON_NOT_APPL;
748 cfm->cfm.status = LCM_PRIM_NOK;
749 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
750 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
751 "invalid action=%d", cntrl->t.cntrl.action);
757 /* Would never come here. */
760 RgMiLrgSchCntrlCfm(cfmPst, cfm);
765 /***********************************************************
767 * Func : SchFillCfmPst
770 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
771 * and the cfm->hdr.response.
778 * File : rg_sch_lmm.c
780 **********************************************************/
782 PUBLIC Void SchFillCfmPst
789 PUBLIC Void SchFillCfmPst(reqPst, cfmPst, cfm)
799 inst = (reqPst->dstInst - SCH_INST_START);
801 cfmPst->srcEnt = ENTRG;
802 cfmPst->srcInst = (Inst) 1;
803 cfmPst->srcProcId = rgSchCb[inst].rgSchInit.procId;
804 cfmPst->dstEnt = ENTRG;
805 cfmPst->dstInst = (Inst) 0;
806 cfmPst->dstProcId = reqPst->srcProcId;
808 cfmPst->selector = cfm->hdr.response.selector;
809 cfmPst->region = cfm->hdr.response.mem.region;
810 cfmPst->pool = cfm->hdr.response.mem.pool;
817 * @brief Timer start handler.
821 * Function : rgSCHLmmStartTmr
823 * This function based on the input parameters starts the timer for
824 * "tmrVal" duration. As of now scheduler instance uses the timer
825 * functionality for BndReq only. Hence there is no conditional
826 * code based on "tmrEvnt".
828 * @param[in] S16 tmrEvnt, the Timer Event
829 * @param[in] U32 tmrVal, the Wait Time
830 * @param[in] PTR cb, Entry for which Timer expired
835 PUBLIC S16 rgSCHLmmStartTmr
838 S16 tmrEvnt, /* Timer Event */
839 U32 tmrVal, /* Wait Time */
840 PTR cb /* Entry for which Timer Expired */
843 PUBLIC S16 rgSCHLmmStartTmr(inst, tmrEvnt, tmrVal, cb)
844 Inst inst; /* scheduler instance ID */
845 S16 tmrEvnt; /* Timer Event */
846 U32 tmrVal; /* Wait Time */
847 PTR cb; /* Entry for which Timer Expired */
851 /* Inst dInst = inst + SCH_INST_START; */
853 TRC2(rgSCHLmmStartTmr)
857 /* Initialize the arg structure */
858 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
860 arg.tqCp = &rgSchCb[inst].tmrTqCp;
861 arg.tq = rgSchCb[inst].tmrTq;
862 arg.timers = &((RgSchLowSapCb *)cb)->tmrBlk;
865 arg.max = RGSCH_MAX_TIMER;
866 arg.evnt = RGSCH_BNDREQ_TMR;
875 * @brief Timer stop handler.
879 * Function : rgSCHLmmStopTmr
881 * This function based on the input parameters stops the timer for
882 * "tmrEvnt". As of now Scheduler instance uses the timer functionality for
883 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
884 * Once the bind happens and this timer is stopped, the timer functionality
885 * is deregistered with SSI. As there is no further use of timer processing.
887 * @param[in] S16 tmrEvnt, the Timer Event
888 * @param[in] PTR cb, Entry for which Timer expired
894 PUBLIC S16 rgSCHLmmStopTmr
896 Inst inst, /* Scheduler instance */
897 S16 tmrEvnt, /* Timer Event */
898 PTR cb /* Entry for which Timer Expired */
901 PUBLIC S16 rgSCHLmmStopTmr(inst, tmrEvnt, cb)
902 Inst inst; /* Scheduler instance */
903 S16 tmrEvnt; /* Timer Event */
904 PTR cb; /* Entry for which Timer Expired */
911 TRC2(rgSCHLmmStopTmr)
915 for(i=0;i<RGSCH_MAX_TIMER;i++)
917 /* Search for the Timer Blocks */
918 if(((RgSchLowSapCb *)cb)->tmrBlk.tmrEvnt == tmrEvnt)
920 /* Initialize the arg structure */
921 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
923 arg.tqCp = &rgSchCb[inst].tmrTqCp;
924 arg.tq = rgSchCb[inst].tmrTq;
925 arg.timers = &(((RgSchLowSapCb *)cb)->tmrBlk);
927 arg.max = RGSCH_MAX_TIMER;
944 * @brief Timer Expiry handler.
948 * Function : rgSCHLmmTmrExpiry
950 * This is a callback function used as an input parameter to cmPrcTmr()
951 * to check expiry of any timer. In this function, we are only concerned
952 * about tmrEvnt=Bind timer.
954 * @param[in] PTR cb, Entry for which Timer expired
955 * @param[in] S16 tmrEvnt, the Timer Event
960 PUBLIC S16 rgSCHLmmTmrExpiry
962 PTR cb, /* Pointer to timer control block */
963 S16 tmrEvnt /* Timer Event */
966 PUBLIC S16 rgSCHLmmTmrExpiry(cb,tmrEvnt)
967 PTR cb; /* Pointer to timer control block */
968 S16 tmrEvnt; /* Timer Event */
972 RgSchLowSapCb *tfuSap = (RgSchLowSapCb *)cb;
974 Inst inst = tfuSap->cell->instIdx;
976 TRC2(rgSCHLmmTmrExpiry)
981 case RGSCH_BNDREQ_TMR:
982 tfuSap->numBndRetries++;
983 if(tfuSap->numBndRetries > RGSCH_MAX_BNDRETRY)
985 rgSCHLmmStaInd((U8)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
986 (U16)LCM_CATEGORY_INTERFACE, (U16)LCM_EVENT_BND_FAIL,
987 (U16)LCM_CAUSE_TMR_EXPIRED, (RgUstaDgn *)NULLP);
991 /* Restart the bind timer */
992 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
994 ret = rgSCHLmmStartTmr((U8)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
996 (U32)tfuSap->sapCfg.bndTmr.val, cb);
999 /* Send bind request */
1000 rgSCHUtlTfuBndReq((U8)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
1001 tfuSap->sapCfg.suId, tfuSap->sapCfg.spId);
1005 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmTmrExpiry(): Invalid"
1006 " tmrEvnt=%d", tmrEvnt);
1015 * @brief Layer Manager Control Confirm generation handler
1016 * for Bind Confirm reception at TFU interface.
1017 * RgLiTfuBndCfm() forwards the confirmation to this
1018 * function. All SAP state related handling is restricted
1019 * to LMM modules, hence the cfm forwarding.
1023 * Function : rgSCHLmmBndCfm
1025 * This API is used by the LIM module of MAC to forward
1026 * the Bind Confirm it receives over the TFU interface.
1028 * @param[in] Pst *pst, Post Structure
1029 * @param[in] SuId suId, Service user ID
1030 * @param[in] U8 status, Status
1035 PUBLIC S16 rgSCHLmmBndCfm
1037 Pst *pst, /* Post Structure */
1038 SuId suId, /* Service user ID */
1039 U8 status /* Status */
1042 PUBLIC S16 rgSCHLmmBndCfm(pst,suId,status)
1043 Pst *pst; /* Post Structure */
1044 SuId suId; /* Service user Id */
1045 U8 status; /* Status */
1051 Inst inst = (pst->dstInst - SCH_INST_START); /* scheduler instance */
1053 TRC2(rgSCHLmmBndCfm)
1056 /* check the SAP State */
1057 switch(rgSchCb[inst].tfuSap[suId].sapSta.sapState)
1059 case LRG_WAIT_BNDCFM:
1062 /* SAP is already bound */
1068 cfmPst = rgSchCb[inst].rgSchInit.lmPst;
1069 cfmPst.selector = rgSchCb[inst].genCfg.bndCfmResp[suId].response.selector;
1070 cfmPst.prior = rgSchCb[inst].genCfg.bndCfmResp[suId].response.prior;
1071 cfmPst.route = rgSchCb[inst].genCfg.bndCfmResp[suId].response.route;
1072 cfmPst.region = rgSchCb[inst].genCfg.bndCfmResp[suId].response.mem.region;
1073 cfmPst.pool = rgSchCb[inst].genCfg.bndCfmResp[suId].response.mem.pool;
1075 cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
1079 case CM_BND_OK: /* status is OK */
1080 /* Change SAP state to Bound */
1081 rgSchCb[inst].tfuSap[suId].sapSta.sapState = LRG_BND;
1082 if (rgSchCb[inst].tfuSap[suId].sapCfg.bndTmr.enb == TRUE)
1084 ret = rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[suId]);
1086 /* Send Control Confirm with status as OK to Layer Manager */
1087 cntrlCfm.cfm.status = LCM_PRIM_OK;
1088 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1089 /* Sending Status Indication to Layer Manager */
1090 rgSCHLmmStaInd((U8)(rgSchCb[inst].tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
1091 LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_OK,
1092 LCM_CAUSE_LYR_SPECIFIC, (RgUstaDgn *)NULLP);
1096 /* Change SAP state to UnBound */
1097 rgSchCb[inst].tfuSap[suId].sapSta.sapState = LRG_UNBND;
1098 if (rgSchCb[inst].tfuSap[suId].sapCfg.bndTmr.enb == TRUE)
1100 ret = rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[suId]);
1102 /* Send Control Confirm with status as NOK to Layer Manager */
1103 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1104 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1107 rgSchCb[inst].tfuSap[suId].numBndRetries = 0;
1108 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1109 cntrlCfm.hdr.transId = rgSchCb[inst].genCfg.bndCfmResp[suId].transId;
1111 ret = RgMiLrgSchCntrlCfm(&cfmPst, &cntrlCfm);
1117 * @brief Layer Manager Unsolicited Status Indication generation.
1121 * Function : rgSCHLmmStaInd
1123 * This API is used by the other modules of MAC to send a unsolicited
1124 * status indication to the Layer Manager.
1126 * @param[in] U16 category, the Alarm category
1127 * @param[in] U16 event, the Alarm event
1128 * @param[in] U16 cause, the cause of the Alarm
1129 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1134 PUBLIC S16 rgSCHLmmStaInd
1143 PUBLIC S16 rgSCHLmmStaInd(inst, category, event, cause, dgn)
1153 TRC2(rgSCHLmmStaInd)
1155 if(rgSchCb[inst].rgSchInit.usta == FALSE)
1160 cmMemset((U8 *)&usta, 0, sizeof(RgMngmt));
1162 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1163 usta.t.usta.cmAlarm.category = category;
1164 usta.t.usta.cmAlarm.event = event;
1165 usta.t.usta.cmAlarm.cause = cause;
1168 cmMemcpy((U8 *)&usta.t.usta.dgn, (U8 *)dgn, sizeof(RgUstaDgn));
1171 rgSchCb[inst].rgSchInit.lmPst.selector =
1172 rgSchCb[inst].genCfg.ustaResp.response.selector;
1173 rgSchCb[inst].rgSchInit.lmPst.prior =
1174 rgSchCb[inst].genCfg.ustaResp.response.prior;
1175 rgSchCb[inst].rgSchInit.lmPst.route =
1176 rgSchCb[inst].genCfg.ustaResp.response.route;
1177 rgSchCb[inst].rgSchInit.lmPst.region =
1178 rgSchCb[inst].genCfg.ustaResp.response.mem.region;
1179 rgSchCb[inst].rgSchInit.lmPst.pool =
1180 rgSchCb[inst].genCfg.ustaResp.response.mem.pool;
1181 usta.hdr.transId = rgSchCb[inst].genCfg.ustaResp.transId;
1183 RETVALUE(RgMiLrgSchStaInd(&rgSchCb[inst].rgSchInit.lmPst, &usta));
1188 * @brief Scheduler instance timer call back function registered with SSI.
1192 * Function : schActvTmr
1194 * This function is invoked by SSI for every timer activation
1195 * period expiry. Note that SS_MT_TMR flag needs to be enabled for this
1196 * as isntId is needed.As part of SRegTmr call for scheduler instance
1197 * SS_MT_TMR flag needs to be enabled and schActvTmr needs to be given as
1204 PUBLIC S16 schActvTmr
1210 PUBLIC S16 schActvTmr(ent, inst)
1215 Inst schInst = (inst - SCH_INST_START);
1218 /* Check if any timer in the scheduler instance has expired */
1219 cmPrcTmr(&rgSchCb[schInst].tmrTqCp,
1220 rgSchCb[schInst].tmrTq, (PFV) rgSCHLmmTmrExpiry);
1224 } /* end of schActvTmr */
1227 /**********************************************************************
1230 **********************************************************************/