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
139 PRIVATE U16 rgSCHLmmSapCfg
142 RgCfg *cfg, /* Configuaration information */
143 U8 sapIdx, /* SAP index */
144 Elmnt sapType /* SAP Type */
147 PRIVATE U16 rgSCHLmmSapCfg(dInst, cfg, sapIdx, sapType)
149 RgCfg *cfg; /* Configuaration information */
150 U8 sapIdx; /* SAP index */
151 Elmnt sapType; /* SAP Type */
154 U16 ret = LCM_REASON_NOT_APPL;
155 RgSchLowSapCfgInfo *lowSapCfg = NULLP;
156 RgSchUpSapCfgInfo *upSapCfg = NULLP;
157 Inst inst = (dInst - SCH_INST_START);
161 /* Check if Gen Config has been done */
167 if ((cfg->s.schInstCfg.rgrSap[sapIdx].selector != RGR_SEL_TC) &&
168 (cfg->s.schInstCfg.rgrSap[sapIdx].selector != RGR_SEL_LC))
170 ret = LCM_REASON_INVALID_PAR_VAL;
171 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
172 " Selector value for RGR.");
176 if(rgSchCb[inst].rgrSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
178 rgSchCb[inst].rgrSap[sapIdx].sapSta.sapState = LRG_UNBND;
180 upSapCfg = &rgSchCb[inst].rgrSap[sapIdx].sapCfg;
182 upSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.rgrSap[sapIdx].ent;
183 upSapCfg->sapPst.dstInst = cfg->s.schInstCfg.rgrSap[sapIdx].inst;
184 upSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.rgrSap[sapIdx].procId;
185 upSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
186 upSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
188 upSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
189 upSapCfg->sapPst.region = cfg->s.schInstCfg.rgrSap[sapIdx].mem.region;
190 upSapCfg->sapPst.pool = cfg->s.schInstCfg.rgrSap[sapIdx].mem.pool;
191 upSapCfg->sapPst.selector = cfg->s.schInstCfg.rgrSap[sapIdx].selector;
192 upSapCfg->sapPst.route = cfg->s.schInstCfg.rgrSap[sapIdx].route;
193 upSapCfg->sapPst.intfVer = 0;
194 upSapCfg->sapPst.event = 0;
195 upSapCfg->sapPst.prior = cfg->s.schInstCfg.rgrSap[sapIdx].prior;
196 upSapCfg->suId = cfg->s.schInstCfg.rgrSap[sapIdx].suId;
197 upSapCfg->spId = cfg->s.schInstCfg.rgrSap[sapIdx].spId;
201 if ((cfg->s.schInstCfg.tfuSap[sapIdx].selector != TFU_SEL_TC) &&
202 (cfg->s.schInstCfg.tfuSap[sapIdx].selector != TFU_SEL_LC))
204 ret = LCM_REASON_INVALID_PAR_VAL;
205 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
206 " Selector value for TFU.");
210 if (rgSchCb[inst].tfuSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
212 rgSchCb[inst].tfuSap[sapIdx].sapSta.sapState = LRG_UNBND;
214 /* Initialize the sap timer */
215 cmInitTimers(&(rgSchCb[inst].tfuSap[sapIdx].tmrBlk), 1);
216 lowSapCfg = &rgSchCb[inst].tfuSap[sapIdx].sapCfg;
218 lowSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.tfuSap[sapIdx].ent;
219 lowSapCfg->sapPst.dstInst = cfg->s.schInstCfg.tfuSap[sapIdx].inst;
220 lowSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.tfuSap[sapIdx].procId;
221 lowSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
222 lowSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
224 lowSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
225 lowSapCfg->sapPst.region = cfg->s.schInstCfg.tfuSap[sapIdx].mem.region;
226 lowSapCfg->sapPst.pool = cfg->s.schInstCfg.tfuSap[sapIdx].mem.pool;
227 lowSapCfg->sapPst.selector = cfg->s.schInstCfg.tfuSap[sapIdx].selector;
228 lowSapCfg->sapPst.route = cfg->s.schInstCfg.tfuSap[sapIdx].route;
229 lowSapCfg->sapPst.intfVer = 0;
230 lowSapCfg->sapPst.event = 0;
231 lowSapCfg->sapPst.prior = cfg->s.schInstCfg.tfuSap[sapIdx].prior;
232 lowSapCfg->suId = cfg->s.schInstCfg.tfuSap[sapIdx].suId;
233 lowSapCfg->spId = cfg->s.schInstCfg.tfuSap[sapIdx].spId;
234 cmMemcpy((U8 *)&lowSapCfg->bndTmr,
235 (U8 *)&cfg->s.schInstCfg.tfuSap[sapIdx].bndTmr,
240 if ((cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_LWLC) &&
241 (cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_LC) &&
242 (cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_TC))
244 ret = LCM_REASON_INVALID_PAR_VAL;
245 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
246 " Selector value for RGM.");
250 if (rgSchCb[inst].rgmSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
252 rgSchCb[inst].rgmSap[sapIdx].sapSta.sapState = LRG_UNBND;
254 upSapCfg = &rgSchCb[inst].rgmSap[sapIdx].sapCfg;
255 upSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.rgmSap[sapIdx].ent;
256 upSapCfg->sapPst.dstInst = cfg->s.schInstCfg.rgmSap[sapIdx].inst;
257 upSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.rgmSap[sapIdx].procId;
258 upSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
259 upSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
261 upSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
262 upSapCfg->sapPst.region = cfg->s.schInstCfg.rgmSap[sapIdx].mem.region;
263 upSapCfg->sapPst.pool = cfg->s.schInstCfg.rgmSap[sapIdx].mem.pool;
264 upSapCfg->sapPst.selector = cfg->s.schInstCfg.rgmSap[sapIdx].selector;
265 upSapCfg->sapPst.route = cfg->s.schInstCfg.rgmSap[sapIdx].route;
266 upSapCfg->sapPst.intfVer = 0;
267 upSapCfg->sapPst.event = 0;
268 upSapCfg->sapPst.prior = cfg->s.schInstCfg.rgmSap[sapIdx].prior;
269 upSapCfg->suId = cfg->s.schInstCfg.rgmSap[sapIdx].suId;
270 upSapCfg->spId = cfg->s.schInstCfg.rgmSap[sapIdx].spId;
274 /* would never reach here */
280 /***********************************************************
282 * Func : rgSCHLmmShutdown
285 * Desc : Handles the scheduler instance shutdown request. Calls
286 * rgSCHCfgFreeCellCb(RgSchCellCb*) to handle each cellCb deallocation.
293 * File : rg_sch_lmm.c
295 **********************************************************/
297 PRIVATE Void rgSCHLmmShutdown
302 PRIVATE Void rgSCHLmmShutdown(inst)
306 Inst dInst = inst + SCH_INST_START;
309 CmLList *lnk = NULLP;
310 RgSchCb *instCb = &rgSchCb[inst];
311 RgSchCellCb *cell = NULLP;
312 RgSchL2MeasCb *measCb;
314 RgSchCmnUlCell *cellUl;
315 RgSchClcBoRpt *bo = NULL;
318 TRC2(rgSCHLmmShutdown)
321 for (idx = 0; idx < instCb->numSaps; idx++)
323 /* got the cell break the loop */
324 cell = instCb->rgrSap[idx].cell;
327 /* Free the memory held up by ulAllocInfo */
328 cellUl = RG_SCH_CMN_GET_UL_CELL(cell);
330 for(ulAllocIdx = 0; ulAllocIdx < RGSCH_SF_ALLOC_SIZE; ulAllocIdx++)
332 for(ulAllocIdx = 0; ulAllocIdx < RGSCH_NUM_SUB_FRAMES; ulAllocIdx++)
335 if(cell->sfAllocArr[ulAllocIdx].ulUeInfo.ulAllocInfo != NULLP)
337 /* ccpu00117052 - MOD - Passing double pointer
338 for proper NULLP assignment*/
339 rgSCHUtlFreeSBuf(cell->instIdx,
340 (Data **)(&(cell->sfAllocArr[ulAllocIdx].ulUeInfo.\
342 cellUl->maxAllocPerUlSf * sizeof(RgInfUeUlAlloc));
345 /* Free the memory allocated to measCb */
346 lnk = cell->l2mList.first;
349 measCb = (RgSchL2MeasCb *)lnk->node;
350 cmLListDelFrm(&cell->l2mList, lnk);
352 /* ccpu00117052 - MOD - Passing double pointer
353 for proper NULLP assignment*/
354 rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&measCb,\
355 sizeof(RgSchL2MeasCb));
358 /* Free mem if any present for boLst for common channels */
359 for(idx = 0; idx < RGSCH_MAX_CMN_LC_CB; idx++)
361 lnk = (CmLList *)cell->cmnLcCb[idx].boLst.first;
364 bo = (RgSchClcBoRpt *)(lnk->node);
366 cmLListDelFrm(&cell->cmnLcCb[idx].boLst, &bo->boLstEnt);
367 rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&bo, sizeof(RgSchClcBoRpt));
375 rgSCHLaaDeInitEnbCb(&rgSchCb[inst]);
377 for (idx = 0; idx < rgSchCb[inst].numSaps; idx++)
379 /* Unbind all the TFU SAP */
380 if(rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_WAIT_BNDCFM)
382 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg, LRG_UNBND);
383 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
385 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[idx]);
387 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
389 if(rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND)
391 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg, LRG_UNBND);
392 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
394 /* Free the memory held by the cell associated with this SAP */
395 if (rgSchCb[inst].tfuSap[idx].cell != NULLP)
396 rgSCHCfgFreeCellCb(rgSchCb[inst].tfuSap[idx].cell);
397 rgSchCb[inst].tfuSap[idx].cell = NULLP;
399 /* Free the memory held by the scheduler instance */
400 /* Deallocate RGR saps */
401 SPutSBuf(rgSchCb[inst].rgSchInit.region,
402 rgSchCb[inst].rgSchInit.pool,
403 (Data *)rgSchCb[inst].rgrSap,
404 (sizeof(RgSchUpSapCb) * rgSchCb[inst].numSaps));
405 rgSchCb[inst].rgrSap = NULLP;
406 /* Deallocate RGM saps */
407 SPutSBuf(rgSchCb[inst].rgSchInit.region,
408 rgSchCb[inst].rgSchInit.pool,
409 (Data *)rgSchCb[inst].rgmSap,
410 (sizeof(RgSchUpSapCb) * rgSchCb[inst].numSaps));
411 rgSchCb[inst].rgmSap = NULLP;
413 /* Deallocate TFU saps */
414 SPutSBuf(rgSchCb[inst].rgSchInit.region,
415 rgSchCb[inst].rgSchInit.pool,
416 (Data *)rgSchCb[inst].tfuSap,
417 (sizeof(RgSchLowSapCb) * rgSchCb[inst].numSaps));
418 rgSchCb[inst].tfuSap = NULLP;
420 /* Deallocate bndCfmResponses */
421 SPutSBuf(rgSchCb[inst].rgSchInit.region,
422 rgSchCb[inst].rgSchInit.pool,
423 (Data *)rgSchCb[inst].genCfg.bndCfmResp,
424 (sizeof(RgSchLmResponse) * rgSchCb[inst].numSaps));
425 rgSchCb[inst].genCfg.bndCfmResp = NULLP;
426 /* De-register the Timer Service */
427 (Void) SDeregTmrMt(rgSchCb[inst].rgSchInit.ent, dInst,
428 (S16)rgSchCb[inst].genCfg.tmrRes, schActvTmr);
430 /* call back the task initialization function to intialize
431 * the global rgSchCb[inst] Struct */
432 schActvInit(rgSchCb[inst].rgSchInit.ent, dInst, rgSchCb[inst].rgSchInit.region,
433 rgSchCb[inst].rgSchInit.reason);
435 /* Set Config done in TskInit */
436 rgSchCb[inst].rgSchInit.cfgDone = FALSE;
442 /***********************************************************
444 * Func : rgSCHLmmGenCntrl
447 * Desc : Processes the LM control request for STGEN elmnt.
454 * File : rg_sch_lmm.c
456 **********************************************************/
458 PUBLIC Void rgSCHLmmGenCntrl
465 PUBLIC Void rgSCHLmmGenCntrl(cntrl, cfm, cfmPst)
471 Inst inst = (cfmPst->srcInst - SCH_INST_START); /* Scheduler instance ID */
472 TRC2(rgSCHLmmGenCntrl)
474 cfm->cfm.status = LCM_PRIM_OK;
475 cfm->cfm.reason = LCM_REASON_NOT_APPL;
478 switch(cntrl->t.cntrl.action)
481 /* Action is Enable */
482 switch(cntrl->t.cntrl.subAction)
485 /* Enable Unsolicited Status (alarms) */
486 rgSchCb[inst].rgSchInit.usta = TRUE;
487 /*Store the response and TransId for sending the Alarms */
488 cmMemcpy((U8 *)&rgSchCb[inst].genCfg.ustaResp.response,
489 (U8 *)&cntrl->hdr.response, sizeof(Resp));
490 rgSchCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
493 /* Enable Debug Printing */
495 rgSchCb[inst].rgSchInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
498 #ifdef PHY_ERROR_LOGING
501 rgSchUlAllocCntr.mcs = cntrl->t.cntrl.s.rgSchUlAllocCntrl.mcs;
502 rgSchUlAllocCntr.numOfRb = cntrl->t.cntrl.s.rgSchUlAllocCntrl.numOfRb;
503 rgSchUlAllocCntr.rbStart = cntrl->t.cntrl.s.rgSchUlAllocCntrl.rbStart;
504 rgSchUlAllocCntr.testStart = cntrl->t.cntrl.s.rgSchUlAllocCntrl.testStart;
505 rgSchUlAllocCntr.enaLog = cntrl->t.cntrl.s.rgSchUlAllocCntrl.enaLog;
506 rgSchUlAllocCntr.logTime = cntrl->t.cntrl.s.rgSchUlAllocCntrl.logTime;
507 rgSchUlAllocCntr.crcOk = 0;
508 rgSchUlAllocCntr.crcErr = 0;
509 rgSchUlAllocCntr.numUlPackets = 0;
510 rgSchUlAllocCntr.numPrach = 0;
511 rgSchUlAllocCntr.taZero = 0;
517 cmMemset((U8 *)&hqRetxStats, 0, sizeof(RgSchHqRetxStats));
518 cmMemset((U8 *)&hqFailStats, 0, sizeof(RgSchNackAckStats));
524 cfm->cfm.status = LCM_PRIM_NOK;
525 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
526 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl(): "
527 "invalid subaction=%d", cntrl->t.cntrl.subAction);
532 /* Action is Diable immidiately */
533 switch(cntrl->t.cntrl.subAction)
536 /* Disable Unsolicited Status (alarms) */
537 rgSchCb[inst].rgSchInit.usta = FALSE;
540 /* Disable Debug Printing */
542 rgSchCb[inst].rgSchInit.dbgMask &=\
543 ~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
548 cfm->cfm.status = LCM_PRIM_NOK;
549 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
550 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl():"
551 " invalid subaction=%d", cntrl->t.cntrl.subAction);
556 /* Free all the memory dynamically allocated by MAC */
557 rgSCHLmmShutdown(inst);
560 cfm->cfm.status = LCM_PRIM_NOK;
561 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
562 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl(): invalid"
563 " action=%d", cntrl->t.cntrl.action);
566 RgMiLrgSchCntrlCfm(cfmPst, cfm);
571 /***********************************************************
573 * Func : rgSCHLmmSapCntrl
576 * Desc : Processes the LM control request for STxxxSAP elmnt.
583 * File : rg_sch_lmm.c
585 **********************************************************/
587 PUBLIC Void rgSCHLmmSapCntrl
594 PUBLIC Void rgSCHLmmSapCntrl(cntrl, cfm, cfmPst)
602 /* TODO Pass InstId instead of using InstId from cfmPst */
603 Inst inst = (cfmPst->srcInst - SCH_INST_START); /* Scheduler instance Id */
604 TRC2(rgSCHLmmSapCntrl)
606 /* Only TFU SAP can be controlled by LM */
607 switch(cntrl->hdr.elmId.elmnt)
610 idx = (U8)cntrl->t.cntrl.s.rgSapCntrl.suId;
611 if (idx > LRG_MAX_SAPS_PER_INST)
613 cfm->cfm.status = LCM_PRIM_NOK;
614 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
616 switch(cntrl->t.cntrl.action)
619 /* Bind Enable Request */
620 if ((rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_NOT_CFG) ||
621 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND))
623 cfm->cfm.status = LCM_PRIM_NOK;
624 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
628 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
630 rgSCHLmmStartTmr(inst, RGSCH_BNDREQ_TMR,
631 rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.val,
632 (PTR)&rgSchCb[inst].tfuSap[idx]);
634 /* Change SAP state */
635 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_WAIT_BNDCFM;
636 rgSchCb[inst].tfuSap[idx].numBndRetries++;
637 /* Store the response and TransId for sending
638 * the Control confirm */
639 cmMemcpy((U8 *)&rgSchCb[inst].genCfg.bndCfmResp[idx].response,
640 (U8 *)&cntrl->hdr.response, sizeof(Resp));
641 rgSchCb[inst].genCfg.bndCfmResp[idx].transId =
644 cfm->cfm.status = LCM_PRIM_OK_NDONE;
645 cfm->cfm.reason = LCM_REASON_NOT_APPL;
647 /* Sending Control Confirm before sending Bind
649 RgMiLrgSchCntrlCfm(cfmPst, cfm);
651 rgSCHUtlTfuBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg.suId,
652 rgSchCb[inst].tfuSap[idx].sapCfg.spId);
659 /* Check if the SAP is configured */
660 if( (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_NOT_CFG) ||
661 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_UNBND))
663 cfm->cfm.status = LCM_PRIM_NOK;
664 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
668 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg,
670 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
672 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR,
673 (PTR)&rgSchCb[inst].tfuSap[idx]);
675 /* Change SAP state */
676 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
677 cfm->cfm.status = LCM_PRIM_OK;
678 cfm->cfm.reason = LCM_REASON_NOT_APPL;
682 /* Delete SAP, does initialization of SAP */
683 if ((rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_WAIT_BNDCFM) ||
684 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND))
686 rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg,
688 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
690 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR,
691 (PTR)&rgSchCb[inst].tfuSap[idx]);
694 cmMemset((U8 *)&rgSchCb[inst].tfuSap[idx], 0, sizeof(RgSchLowSapCb));
695 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_NOT_CFG;
696 cfm->cfm.status = LCM_PRIM_OK;
697 cfm->cfm.reason = LCM_REASON_NOT_APPL;
700 cfm->cfm.status = LCM_PRIM_NOK;
701 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
702 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
703 "invalid action=%d", cntrl->t.cntrl.action);
708 idx = (U8)cntrl->t.cntrl.s.rgSapCntrl.spId;
709 if (idx > LRG_MAX_SAPS_PER_INST)
711 cfm->cfm.status = LCM_PRIM_NOK;
712 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
714 switch(cntrl->t.cntrl.action)
717 cmMemset((U8 *)&rgSchCb[inst].rgrSap[idx], 0, sizeof(RgSchUpSapCb));
718 rgSchCb[inst].rgrSap[idx].sapSta.sapState = LRG_NOT_CFG;
719 cfm->cfm.status = LCM_PRIM_OK;
720 cfm->cfm.reason = LCM_REASON_NOT_APPL;
723 cfm->cfm.status = LCM_PRIM_NOK;
724 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
725 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
726 "invalid action=%d", cntrl->t.cntrl.action);
731 idx = (U8)cntrl->t.cntrl.s.rgSapCntrl.spId;
732 if (idx > LRG_MAX_SAPS_PER_INST)
734 cfm->cfm.status = LCM_PRIM_NOK;
735 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
737 switch(cntrl->t.cntrl.action)
740 cmMemset((U8 *)&rgSchCb[inst].rgmSap[idx], 0, sizeof(RgSchUpSapCb));
741 rgSchCb[inst].rgmSap[idx].sapSta.sapState = LRG_NOT_CFG;
742 cfm->cfm.status = LCM_PRIM_OK;
743 cfm->cfm.reason = LCM_REASON_NOT_APPL;
746 cfm->cfm.status = LCM_PRIM_NOK;
747 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
748 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
749 "invalid action=%d", cntrl->t.cntrl.action);
755 /* Would never come here. */
758 RgMiLrgSchCntrlCfm(cfmPst, cfm);
763 /***********************************************************
765 * Func : SchFillCfmPst
768 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
769 * and the cfm->hdr.response.
776 * File : rg_sch_lmm.c
778 **********************************************************/
780 PUBLIC Void SchFillCfmPst
787 PUBLIC Void SchFillCfmPst(reqPst, cfmPst, cfm)
797 inst = (reqPst->dstInst - SCH_INST_START);
799 cfmPst->srcEnt = ENTRG;
800 cfmPst->srcInst = (Inst) 1;
801 cfmPst->srcProcId = rgSchCb[inst].rgSchInit.procId;
802 cfmPst->dstEnt = ENTRG;
803 cfmPst->dstInst = (Inst) 0;
804 cfmPst->dstProcId = reqPst->srcProcId;
806 cfmPst->selector = cfm->hdr.response.selector;
807 cfmPst->region = cfm->hdr.response.mem.region;
808 cfmPst->pool = cfm->hdr.response.mem.pool;
815 * @brief Timer start handler.
819 * Function : rgSCHLmmStartTmr
821 * This function based on the input parameters starts the timer for
822 * "tmrVal" duration. As of now scheduler instance uses the timer
823 * functionality for BndReq only. Hence there is no conditional
824 * code based on "tmrEvnt".
826 * @param[in] S16 tmrEvnt, the Timer Event
827 * @param[in] U32 tmrVal, the Wait Time
828 * @param[in] PTR cb, Entry for which Timer expired
833 PUBLIC S16 rgSCHLmmStartTmr
836 S16 tmrEvnt, /* Timer Event */
837 U32 tmrVal, /* Wait Time */
838 PTR cb /* Entry for which Timer Expired */
841 PUBLIC S16 rgSCHLmmStartTmr(inst, tmrEvnt, tmrVal, cb)
842 Inst inst; /* scheduler instance ID */
843 S16 tmrEvnt; /* Timer Event */
844 U32 tmrVal; /* Wait Time */
845 PTR cb; /* Entry for which Timer Expired */
849 /* Inst dInst = inst + SCH_INST_START; */
851 TRC2(rgSCHLmmStartTmr)
855 /* Initialize the arg structure */
856 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
858 arg.tqCp = &rgSchCb[inst].tmrTqCp;
859 arg.tq = rgSchCb[inst].tmrTq;
860 arg.timers = &((RgSchLowSapCb *)cb)->tmrBlk;
863 arg.max = RGSCH_MAX_TIMER;
864 arg.evnt = RGSCH_BNDREQ_TMR;
873 * @brief Timer stop handler.
877 * Function : rgSCHLmmStopTmr
879 * This function based on the input parameters stops the timer for
880 * "tmrEvnt". As of now Scheduler instance uses the timer functionality for
881 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
882 * Once the bind happens and this timer is stopped, the timer functionality
883 * is deregistered with SSI. As there is no further use of timer processing.
885 * @param[in] S16 tmrEvnt, the Timer Event
886 * @param[in] PTR cb, Entry for which Timer expired
892 PUBLIC S16 rgSCHLmmStopTmr
894 Inst inst, /* Scheduler instance */
895 S16 tmrEvnt, /* Timer Event */
896 PTR cb /* Entry for which Timer Expired */
899 PUBLIC S16 rgSCHLmmStopTmr(inst, tmrEvnt, cb)
900 Inst inst; /* Scheduler instance */
901 S16 tmrEvnt; /* Timer Event */
902 PTR cb; /* Entry for which Timer Expired */
909 TRC2(rgSCHLmmStopTmr)
913 for(i=0;i<RGSCH_MAX_TIMER;i++)
915 /* Search for the Timer Blocks */
916 if(((RgSchLowSapCb *)cb)->tmrBlk.tmrEvnt == tmrEvnt)
918 /* Initialize the arg structure */
919 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
921 arg.tqCp = &rgSchCb[inst].tmrTqCp;
922 arg.tq = rgSchCb[inst].tmrTq;
923 arg.timers = &(((RgSchLowSapCb *)cb)->tmrBlk);
925 arg.max = RGSCH_MAX_TIMER;
942 * @brief Timer Expiry handler.
946 * Function : rgSCHLmmTmrExpiry
948 * This is a callback function used as an input parameter to cmPrcTmr()
949 * to check expiry of any timer. In this function, we are only concerned
950 * about tmrEvnt=Bind timer.
952 * @param[in] PTR cb, Entry for which Timer expired
953 * @param[in] S16 tmrEvnt, the Timer Event
958 PUBLIC S16 rgSCHLmmTmrExpiry
960 PTR cb, /* Pointer to timer control block */
961 S16 tmrEvnt /* Timer Event */
964 PUBLIC S16 rgSCHLmmTmrExpiry(cb,tmrEvnt)
965 PTR cb; /* Pointer to timer control block */
966 S16 tmrEvnt; /* Timer Event */
970 RgSchLowSapCb *tfuSap = (RgSchLowSapCb *)cb;
972 Inst inst = tfuSap->cell->instIdx;
974 TRC2(rgSCHLmmTmrExpiry)
979 case RGSCH_BNDREQ_TMR:
980 tfuSap->numBndRetries++;
981 if(tfuSap->numBndRetries > RGSCH_MAX_BNDRETRY)
983 rgSCHLmmStaInd((U8)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
984 (U16)LCM_CATEGORY_INTERFACE, (U16)LCM_EVENT_BND_FAIL,
985 (U16)LCM_CAUSE_TMR_EXPIRED, (RgUstaDgn *)NULLP);
989 /* Restart the bind timer */
990 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
992 ret = rgSCHLmmStartTmr((U8)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
994 (U32)tfuSap->sapCfg.bndTmr.val, cb);
997 /* Send bind request */
998 rgSCHUtlTfuBndReq((U8)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
999 tfuSap->sapCfg.suId, tfuSap->sapCfg.spId);
1003 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmTmrExpiry(): Invalid"
1004 " tmrEvnt=%d", tmrEvnt);
1013 * @brief Layer Manager Control Confirm generation handler
1014 * for Bind Confirm reception at TFU interface.
1015 * RgLiTfuBndCfm() forwards the confirmation to this
1016 * function. All SAP state related handling is restricted
1017 * to LMM modules, hence the cfm forwarding.
1021 * Function : rgSCHLmmBndCfm
1023 * This API is used by the LIM module of MAC to forward
1024 * the Bind Confirm it receives over the TFU interface.
1026 * @param[in] Pst *pst, Post Structure
1027 * @param[in] SuId suId, Service user ID
1028 * @param[in] U8 status, Status
1033 PUBLIC S16 rgSCHLmmBndCfm
1035 Pst *pst, /* Post Structure */
1036 SuId suId, /* Service user ID */
1037 U8 status /* Status */
1040 PUBLIC S16 rgSCHLmmBndCfm(pst,suId,status)
1041 Pst *pst; /* Post Structure */
1042 SuId suId; /* Service user Id */
1043 U8 status; /* Status */
1049 Inst inst = (pst->dstInst - SCH_INST_START); /* scheduler instance */
1051 TRC2(rgSCHLmmBndCfm)
1054 /* check the SAP State */
1055 switch(rgSchCb[inst].tfuSap[suId].sapSta.sapState)
1057 case LRG_WAIT_BNDCFM:
1060 /* SAP is already bound */
1066 cfmPst = rgSchCb[inst].rgSchInit.lmPst;
1067 cfmPst.selector = rgSchCb[inst].genCfg.bndCfmResp[suId].response.selector;
1068 cfmPst.prior = rgSchCb[inst].genCfg.bndCfmResp[suId].response.prior;
1069 cfmPst.route = rgSchCb[inst].genCfg.bndCfmResp[suId].response.route;
1070 cfmPst.region = rgSchCb[inst].genCfg.bndCfmResp[suId].response.mem.region;
1071 cfmPst.pool = rgSchCb[inst].genCfg.bndCfmResp[suId].response.mem.pool;
1073 cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
1077 case CM_BND_OK: /* status is OK */
1078 /* Change SAP state to Bound */
1079 rgSchCb[inst].tfuSap[suId].sapSta.sapState = LRG_BND;
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 OK to Layer Manager */
1085 cntrlCfm.cfm.status = LCM_PRIM_OK;
1086 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1087 /* Sending Status Indication to Layer Manager */
1088 rgSCHLmmStaInd((U8)(rgSchCb[inst].tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
1089 LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_OK,
1090 LCM_CAUSE_LYR_SPECIFIC, (RgUstaDgn *)NULLP);
1094 /* Change SAP state to UnBound */
1095 rgSchCb[inst].tfuSap[suId].sapSta.sapState = LRG_UNBND;
1096 if (rgSchCb[inst].tfuSap[suId].sapCfg.bndTmr.enb == TRUE)
1098 ret = rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[suId]);
1100 /* Send Control Confirm with status as NOK to Layer Manager */
1101 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1102 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1105 rgSchCb[inst].tfuSap[suId].numBndRetries = 0;
1106 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1107 cntrlCfm.hdr.transId = rgSchCb[inst].genCfg.bndCfmResp[suId].transId;
1109 ret = RgMiLrgSchCntrlCfm(&cfmPst, &cntrlCfm);
1115 * @brief Layer Manager Unsolicited Status Indication generation.
1119 * Function : rgSCHLmmStaInd
1121 * This API is used by the other modules of MAC to send a unsolicited
1122 * status indication to the Layer Manager.
1124 * @param[in] U16 category, the Alarm category
1125 * @param[in] U16 event, the Alarm event
1126 * @param[in] U16 cause, the cause of the Alarm
1127 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1132 PUBLIC S16 rgSCHLmmStaInd
1141 PUBLIC S16 rgSCHLmmStaInd(inst, category, event, cause, dgn)
1151 TRC2(rgSCHLmmStaInd)
1153 if(rgSchCb[inst].rgSchInit.usta == FALSE)
1158 cmMemset((U8 *)&usta, 0, sizeof(RgMngmt));
1160 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1161 usta.t.usta.cmAlarm.category = category;
1162 usta.t.usta.cmAlarm.event = event;
1163 usta.t.usta.cmAlarm.cause = cause;
1166 cmMemcpy((U8 *)&usta.t.usta.dgn, (U8 *)dgn, sizeof(RgUstaDgn));
1169 rgSchCb[inst].rgSchInit.lmPst.selector =
1170 rgSchCb[inst].genCfg.ustaResp.response.selector;
1171 rgSchCb[inst].rgSchInit.lmPst.prior =
1172 rgSchCb[inst].genCfg.ustaResp.response.prior;
1173 rgSchCb[inst].rgSchInit.lmPst.route =
1174 rgSchCb[inst].genCfg.ustaResp.response.route;
1175 rgSchCb[inst].rgSchInit.lmPst.region =
1176 rgSchCb[inst].genCfg.ustaResp.response.mem.region;
1177 rgSchCb[inst].rgSchInit.lmPst.pool =
1178 rgSchCb[inst].genCfg.ustaResp.response.mem.pool;
1179 usta.hdr.transId = rgSchCb[inst].genCfg.ustaResp.transId;
1181 RETVALUE(RgMiLrgSchStaInd(&rgSchCb[inst].rgSchInit.lmPst, &usta));
1186 * @brief Scheduler instance timer call back function registered with SSI.
1190 * Function : schActvTmr
1192 * This function is invoked by SSI for every timer activation
1193 * period expiry. Note that SS_MT_TMR flag needs to be enabled for this
1194 * as isntId is needed.As part of SRegTmr call for scheduler instance
1195 * SS_MT_TMR flag needs to be enabled and schActvTmr needs to be given as
1202 PUBLIC S16 schActvTmr
1208 PUBLIC S16 schActvTmr(ent, inst)
1213 Inst schInst = (inst - SCH_INST_START);
1216 /* Check if any timer in the scheduler instance has expired */
1217 cmPrcTmr(&rgSchCb[schInst].tmrTqCp,
1218 rgSchCb[schInst].tmrTq, (PFV) rgSCHLmmTmrExpiry);
1222 } /* end of schActvTmr */
1225 /**********************************************************************
1228 **********************************************************************/