1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /************************************************************************
25 Desc: C source code for Layer Manager Interface Module
29 **********************************************************************/
31 /** @file rg_sch_lmm.c
32 @brief This file contains the Layer Management interface module implementation for scheduler.
33 The functions for the configuration, control, status and statistics
34 request primitives are defined here.
37 static const char* RLOG_MODULE_NAME="MAC";
38 static int RLOG_MODULE_ID=4096;
39 static int RLOG_FILE_ID=167;
41 /* header include files (.h) */
42 #include "common_def.h"
43 #include "rg_env.h" /* MAC Environment Defines */
44 #include "rgr.h" /* RGR Interface defines */
45 #include "tfu.h" /* RGU Interface defines */
46 #include "lrg.h" /* LRG Interface defines */
47 #include "rgm.h" /* RGM Interface defines */
48 #include "rg_sch.h" /* Scheduler defines */
49 #include "rg_sch_inf.h" /* Scheduler defines */
50 #include "rg_sch_err.h" /* MAC error defines */
52 #include "rg_sch_cmn.h" /* typedefs for Scheduler */
54 #include "rl_interface.h"
55 #include "rl_common.h"
57 /* header/extern include files (.x) */
58 #include "rgr.x" /* RGR Interface includes */
59 #include "rgm.x" /* RGM Interface includes */
60 #include "tfu.x" /* RGU Interface includes */
61 #include "lrg.x" /* LRG Interface includes */
62 #include "rg_sch_inf.x" /* Scheduler defines */
63 #include "rg_sch.x" /* Scheduler includes */
65 #include "rg_sch_cmn.x" /* typedefs for Scheduler */
68 Void rgSCHCmnInit ARGS((Void));
70 /* forward references */
71 extern int schActvInit(Ent entity, Inst instId, Region region, Reason reason);
73 static uint16_t rgSCHLmmSapCfg ARGS((
80 static Void rgSCHLmmShutdown ARGS((
85 void printSchCellInfo(void)
89 for (idx = 0; idx < rgSchCb[inst].numSaps; idx++)
91 /* Unbind all the TFU SAP */
92 /* Free the memory held by the cell associated
94 if (rgSchCb[inst].tfuSap[idx].cell != NULLP)
96 RLOG1(L_INFO,"CELL %d\n", idx);
97 RLOG1(L_INFO,"NUM UEs :%d\n",rgSchCb[inst].tfuSap[idx].cell->ueLst.nmbEnt);
103 * @brief SAP Configuration Handler.
107 * Function : rgSCHLmmSapCfg
109 * This function in called by SchProcGenCfgReq(). It handles the
110 * interface SAP configuration of the scheduler instance. It
111 * initializes the sapState to LRG_UNBND. Returns
112 * reason for success/failure of this function.
114 * @param[in] RgCfg *cfg, the Configuaration information
116 * -# LCM_REASON_GENCFG_NOT_DONE
117 * -# LCM_REASON_INVALID_SAP
118 * -# LCM_REASON_NOT_APPL
121 static uint16_t rgSCHLmmSapCfg
124 RgCfg *cfg, /* Configuaration information */
125 uint8_t sapIdx, /* SAP index */
126 Elmnt sapType /* SAP Type */
129 uint16_t ret = LCM_REASON_NOT_APPL;
130 RgSchLowSapCfgInfo *lowSapCfg = NULLP;
131 RgSchUpSapCfgInfo *upSapCfg = NULLP;
132 Inst inst = (dInst - SCH_INST_START);
134 /* Check if Gen Config has been done */
140 if ((cfg->s.schInstCfg.rgrSap[sapIdx].selector != ODU_SELECTOR_TC) &&
141 (cfg->s.schInstCfg.rgrSap[sapIdx].selector != ODU_SELECTOR_LC))
143 ret = LCM_REASON_INVALID_PAR_VAL;
144 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
145 " Selector value for RGR.");
149 if(rgSchCb[inst].rgrSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
151 rgSchCb[inst].rgrSap[sapIdx].sapSta.sapState = LRG_UNBND;
153 upSapCfg = &rgSchCb[inst].rgrSap[sapIdx].sapCfg;
155 upSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.rgrSap[sapIdx].ent;
156 upSapCfg->sapPst.dstInst = cfg->s.schInstCfg.rgrSap[sapIdx].inst;
157 upSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.rgrSap[sapIdx].procId;
158 upSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
159 upSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
161 upSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
162 upSapCfg->sapPst.region = cfg->s.schInstCfg.rgrSap[sapIdx].mem.region;
163 upSapCfg->sapPst.pool = cfg->s.schInstCfg.rgrSap[sapIdx].mem.pool;
164 upSapCfg->sapPst.selector = cfg->s.schInstCfg.rgrSap[sapIdx].selector;
165 upSapCfg->sapPst.route = cfg->s.schInstCfg.rgrSap[sapIdx].route;
166 upSapCfg->sapPst.intfVer = 0;
167 upSapCfg->sapPst.event = 0;
168 upSapCfg->sapPst.prior = cfg->s.schInstCfg.rgrSap[sapIdx].prior;
169 upSapCfg->suId = cfg->s.schInstCfg.rgrSap[sapIdx].suId;
170 upSapCfg->spId = cfg->s.schInstCfg.rgrSap[sapIdx].spId;
174 if ((cfg->s.schInstCfg.tfuSap[sapIdx].selector != ODU_SELECTOR_TC) &&
175 (cfg->s.schInstCfg.tfuSap[sapIdx].selector != ODU_SELECTOR_LC))
177 ret = LCM_REASON_INVALID_PAR_VAL;
178 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
179 " Selector value for TFU.");
183 if (rgSchCb[inst].tfuSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
185 rgSchCb[inst].tfuSap[sapIdx].sapSta.sapState = LRG_UNBND;
187 /* Initialize the sap timer */
188 cmInitTimers(&(rgSchCb[inst].tfuSap[sapIdx].tmrBlk), 1);
189 lowSapCfg = &rgSchCb[inst].tfuSap[sapIdx].sapCfg;
191 lowSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.tfuSap[sapIdx].ent;
192 lowSapCfg->sapPst.dstInst = cfg->s.schInstCfg.tfuSap[sapIdx].inst;
193 lowSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.tfuSap[sapIdx].procId;
194 lowSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
195 lowSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
197 lowSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
198 lowSapCfg->sapPst.region = cfg->s.schInstCfg.tfuSap[sapIdx].mem.region;
199 lowSapCfg->sapPst.pool = cfg->s.schInstCfg.tfuSap[sapIdx].mem.pool;
200 lowSapCfg->sapPst.selector = cfg->s.schInstCfg.tfuSap[sapIdx].selector;
201 lowSapCfg->sapPst.route = cfg->s.schInstCfg.tfuSap[sapIdx].route;
202 lowSapCfg->sapPst.intfVer = 0;
203 lowSapCfg->sapPst.event = 0;
204 lowSapCfg->sapPst.prior = cfg->s.schInstCfg.tfuSap[sapIdx].prior;
205 lowSapCfg->suId = cfg->s.schInstCfg.tfuSap[sapIdx].suId;
206 lowSapCfg->spId = cfg->s.schInstCfg.tfuSap[sapIdx].spId;
207 memcpy(&lowSapCfg->bndTmr,
208 &cfg->s.schInstCfg.tfuSap[sapIdx].bndTmr,
213 if ((cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_LWLC) &&
214 (cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_LC) &&
215 (cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_TC))
217 ret = LCM_REASON_INVALID_PAR_VAL;
218 RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
219 " Selector value for RGM.");
223 if (rgSchCb[inst].rgmSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
225 rgSchCb[inst].rgmSap[sapIdx].sapSta.sapState = LRG_UNBND;
227 upSapCfg = &rgSchCb[inst].rgmSap[sapIdx].sapCfg;
228 upSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.rgmSap[sapIdx].ent;
229 upSapCfg->sapPst.dstInst = cfg->s.schInstCfg.rgmSap[sapIdx].inst;
230 upSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.rgmSap[sapIdx].procId;
231 upSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
232 upSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
234 upSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
235 upSapCfg->sapPst.region = cfg->s.schInstCfg.rgmSap[sapIdx].mem.region;
236 upSapCfg->sapPst.pool = cfg->s.schInstCfg.rgmSap[sapIdx].mem.pool;
237 upSapCfg->sapPst.selector = cfg->s.schInstCfg.rgmSap[sapIdx].selector;
238 upSapCfg->sapPst.route = cfg->s.schInstCfg.rgmSap[sapIdx].route;
239 upSapCfg->sapPst.intfVer = 0;
240 upSapCfg->sapPst.event = 0;
241 upSapCfg->sapPst.prior = cfg->s.schInstCfg.rgmSap[sapIdx].prior;
242 upSapCfg->suId = cfg->s.schInstCfg.rgmSap[sapIdx].suId;
243 upSapCfg->spId = cfg->s.schInstCfg.rgmSap[sapIdx].spId;
247 /* would never reach here */
254 /***********************************************************
256 * Func : rgSCHLmmShutdown
259 * Desc : Handles the scheduler instance shutdown request. Calls
260 * rgSCHCfgFreeCellCb(RgSchCellCb*) to handle each cellCb deallocation.
267 * File : rg_sch_lmm.c
269 **********************************************************/
270 static Void rgSCHLmmShutdown(Inst inst)
272 Inst dInst = inst + SCH_INST_START;
275 CmLList *lnk = NULLP;
276 RgSchCb *instCb = &rgSchCb[inst];
277 RgSchCellCb *cell = NULLP;
278 RgSchL2MeasCb *measCb;
280 RgSchCmnUlCell *cellUl;
281 RgSchClcBoRpt *bo = NULL;
285 for (idx = 0; idx < instCb->numSaps; idx++)
287 /* got the cell break the loop */
288 cell = instCb->rgrSap[idx].cell;
291 /* Free the memory held up by ulAllocInfo */
292 cellUl = RG_SCH_CMN_GET_UL_CELL(cell);
294 for(ulAllocIdx = 0; ulAllocIdx < RGSCH_SF_ALLOC_SIZE; ulAllocIdx++)
296 for(ulAllocIdx = 0; ulAllocIdx < RGSCH_NUM_SUB_FRAMES; ulAllocIdx++)
299 if(cell->sfAllocArr[ulAllocIdx].ulUeInfo.ulAllocInfo != NULLP)
301 /* ccpu00117052 - MOD - Passing double pointer
302 for proper NULLP assignment*/
303 rgSCHUtlFreeSBuf(cell->instIdx,
304 (Data **)(&(cell->sfAllocArr[ulAllocIdx].ulUeInfo.\
306 cellUl->maxAllocPerUlSf * sizeof(RgInfUeUlAlloc));
309 /* Free the memory allocated to measCb */
310 lnk = cell->l2mList.first;
313 measCb = (RgSchL2MeasCb *)lnk->node;
314 cmLListDelFrm(&cell->l2mList, lnk);
316 /* ccpu00117052 - MOD - Passing double pointer
317 for proper NULLP assignment*/
318 rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&measCb,\
319 sizeof(RgSchL2MeasCb));
322 /* Free mem if any present for boLst for common channels */
323 for(idx = 0; idx < RGSCH_MAX_CMN_LC_CB; idx++)
325 lnk = (CmLList *)cell->cmnLcCb[idx].boLst.first;
328 bo = (RgSchClcBoRpt *)(lnk->node);
330 cmLListDelFrm(&cell->cmnLcCb[idx].boLst, &bo->boLstEnt);
331 rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&bo, sizeof(RgSchClcBoRpt));
339 rgSCHLaaDeInitEnbCb(&rgSchCb[inst]);
341 for (idx = 0; idx < rgSchCb[inst].numSaps; idx++)
343 /* Unbind all the TFU SAP */
344 if(rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_WAIT_BNDCFM)
346 //rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg, LRG_UNBND);
347 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
349 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[idx]);
351 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
353 if(rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND)
355 //rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg, LRG_UNBND);
356 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
358 /* Free the memory held by the cell associated with this SAP */
359 if (rgSchCb[inst].tfuSap[idx].cell != NULLP)
360 rgSCHCfgFreeCellCb(rgSchCb[inst].tfuSap[idx].cell);
361 rgSchCb[inst].tfuSap[idx].cell = NULLP;
363 /* Free the memory held by the scheduler instance */
364 /* Deallocate RGR saps */
365 SPutSBuf(rgSchCb[inst].rgSchInit.region,
366 rgSchCb[inst].rgSchInit.pool,
367 (Data *)rgSchCb[inst].rgrSap,
368 (sizeof(RgSchUpSapCb) * rgSchCb[inst].numSaps));
369 rgSchCb[inst].rgrSap = NULLP;
370 /* Deallocate RGM saps */
371 SPutSBuf(rgSchCb[inst].rgSchInit.region,
372 rgSchCb[inst].rgSchInit.pool,
373 (Data *)rgSchCb[inst].rgmSap,
374 (sizeof(RgSchUpSapCb) * rgSchCb[inst].numSaps));
375 rgSchCb[inst].rgmSap = NULLP;
377 /* Deallocate TFU saps */
378 SPutSBuf(rgSchCb[inst].rgSchInit.region,
379 rgSchCb[inst].rgSchInit.pool,
380 (Data *)rgSchCb[inst].tfuSap,
381 (sizeof(RgSchLowSapCb) * rgSchCb[inst].numSaps));
382 rgSchCb[inst].tfuSap = NULLP;
384 /* Deallocate bndCfmResponses */
385 SPutSBuf(rgSchCb[inst].rgSchInit.region,
386 rgSchCb[inst].rgSchInit.pool,
387 (Data *)rgSchCb[inst].genCfg.bndCfmResp,
388 (sizeof(RgSchLmResponse) * rgSchCb[inst].numSaps));
389 rgSchCb[inst].genCfg.bndCfmResp = NULLP;
390 /* De-register the Timer Service */
391 (Void) SDeregTmrMt(rgSchCb[inst].rgSchInit.ent, dInst,
392 (S16)rgSchCb[inst].genCfg.tmrRes, schActvTmr);
394 /* call back the task initialization function to intialize
395 * the global rgSchCb[inst] Struct */
396 schActvInit(rgSchCb[inst].rgSchInit.ent, dInst, rgSchCb[inst].rgSchInit.region,
397 rgSchCb[inst].rgSchInit.reason);
399 /* Set Config done in TskInit */
400 rgSchCb[inst].rgSchInit.cfgDone = FALSE;
406 /***********************************************************
408 * Func : rgSCHLmmGenCntrl
411 * Desc : Processes the LM control request for STGEN elmnt.
418 * File : rg_sch_lmm.c
420 **********************************************************/
421 Void rgSCHLmmGenCntrl(RgMngmt *cntrl,RgMngmt *cfm,Pst *cfmPst)
423 Inst inst = (cfmPst->srcInst - SCH_INST_START); /* Scheduler instance ID */
425 cfm->cfm.status = LCM_PRIM_OK;
426 cfm->cfm.reason = LCM_REASON_NOT_APPL;
429 switch(cntrl->t.cntrl.action)
432 /* Action is Enable */
433 switch(cntrl->t.cntrl.subAction)
436 /* Enable Unsolicited Status (alarms) */
437 rgSchCb[inst].rgSchInit.usta = TRUE;
438 /*Store the response and TransId for sending the Alarms */
439 memcpy(&rgSchCb[inst].genCfg.ustaResp.response,
440 &cntrl->hdr.response, sizeof(Resp));
441 rgSchCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
444 /* Enable Debug Printing */
446 rgSchCb[inst].rgSchInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
449 #ifdef PHY_ERROR_LOGING
452 rgSchUlAllocCntr.mcs = cntrl->t.cntrl.s.rgSchUlAllocCntrl.mcs;
453 rgSchUlAllocCntr.numOfRb = cntrl->t.cntrl.s.rgSchUlAllocCntrl.numOfRb;
454 rgSchUlAllocCntr.rbStart = cntrl->t.cntrl.s.rgSchUlAllocCntrl.rbStart;
455 rgSchUlAllocCntr.testStart = cntrl->t.cntrl.s.rgSchUlAllocCntrl.testStart;
456 rgSchUlAllocCntr.enaLog = cntrl->t.cntrl.s.rgSchUlAllocCntrl.enaLog;
457 rgSchUlAllocCntr.logTime = cntrl->t.cntrl.s.rgSchUlAllocCntrl.logTime;
458 rgSchUlAllocCntr.crcOk = 0;
459 rgSchUlAllocCntr.crcErr = 0;
460 rgSchUlAllocCntr.numUlPackets = 0;
461 rgSchUlAllocCntr.numPrach = 0;
462 rgSchUlAllocCntr.taZero = 0;
468 memset(&hqRetxStats, 0, sizeof(RgSchHqRetxStats));
469 memset(&hqFailStats, 0, sizeof(RgSchNackAckStats));
475 cfm->cfm.status = LCM_PRIM_NOK;
476 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
477 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl(): "
478 "invalid subaction=%d", cntrl->t.cntrl.subAction);
483 /* Action is Diable immidiately */
484 switch(cntrl->t.cntrl.subAction)
487 /* Disable Unsolicited Status (alarms) */
488 rgSchCb[inst].rgSchInit.usta = FALSE;
491 /* Disable Debug Printing */
493 rgSchCb[inst].rgSchInit.dbgMask &=\
494 ~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
499 cfm->cfm.status = LCM_PRIM_NOK;
500 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
501 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl():"
502 " invalid subaction=%d", cntrl->t.cntrl.subAction);
507 /* Free all the memory dynamically allocated by MAC */
508 rgSCHLmmShutdown(inst);
511 cfm->cfm.status = LCM_PRIM_NOK;
512 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
513 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl(): invalid"
514 " action=%d", cntrl->t.cntrl.action);
517 RgMiLrgSchCntrlCfm(cfmPst, cfm);
522 /***********************************************************
524 * Func : rgSCHLmmSapCntrl
527 * Desc : Processes the LM control request for STxxxSAP elmnt.
534 * File : rg_sch_lmm.c
536 **********************************************************/
537 Void rgSCHLmmSapCntrl
546 /* TODO Pass InstId instead of using InstId from cfmPst */
547 Inst inst = (cfmPst->srcInst - SCH_INST_START); /* Scheduler instance Id */
549 /* Only TFU SAP can be controlled by LM */
550 switch(cntrl->hdr.elmId.elmnt)
553 idx = (uint8_t)cntrl->t.cntrl.s.rgSapCntrl.suId;
554 if (idx > LRG_MAX_SAPS_PER_INST)
556 cfm->cfm.status = LCM_PRIM_NOK;
557 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
559 switch(cntrl->t.cntrl.action)
562 /* Bind Enable Request */
563 if ((rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_NOT_CFG) ||
564 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND))
566 cfm->cfm.status = LCM_PRIM_NOK;
567 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
571 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
573 rgSCHLmmStartTmr(inst, RGSCH_BNDREQ_TMR,
574 rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.val,
575 (PTR)&rgSchCb[inst].tfuSap[idx]);
577 /* Change SAP state */
578 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_WAIT_BNDCFM;
579 rgSchCb[inst].tfuSap[idx].numBndRetries++;
580 /* Store the response and TransId for sending
581 * the Control confirm */
582 memcpy(&rgSchCb[inst].genCfg.bndCfmResp[idx].response,
583 &cntrl->hdr.response, sizeof(Resp));
584 rgSchCb[inst].genCfg.bndCfmResp[idx].transId =
587 cfm->cfm.status = LCM_PRIM_OK_NDONE;
588 cfm->cfm.reason = LCM_REASON_NOT_APPL;
590 /* Sending Control Confirm before sending Bind
592 RgMiLrgSchCntrlCfm(cfmPst, cfm);
594 //rgSCHUtlTfuBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg.suId,
595 // rgSchCb[inst].tfuSap[idx].sapCfg.spId);
602 /* Check if the SAP is configured */
603 if( (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_NOT_CFG) ||
604 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_UNBND))
606 cfm->cfm.status = LCM_PRIM_NOK;
607 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
611 //rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg,
612 // TFU_UBNDREQ_MNGMT);
613 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
615 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR,
616 (PTR)&rgSchCb[inst].tfuSap[idx]);
618 /* Change SAP state */
619 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
620 cfm->cfm.status = LCM_PRIM_OK;
621 cfm->cfm.reason = LCM_REASON_NOT_APPL;
625 /* Delete SAP, does initialization of SAP */
626 if ((rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_WAIT_BNDCFM) ||
627 (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND))
629 //rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg,
630 // TFU_UBNDREQ_MNGMT);
631 if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
633 rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR,
634 (PTR)&rgSchCb[inst].tfuSap[idx]);
637 memset(&rgSchCb[inst].tfuSap[idx], 0, sizeof(RgSchLowSapCb));
638 rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_NOT_CFG;
639 cfm->cfm.status = LCM_PRIM_OK;
640 cfm->cfm.reason = LCM_REASON_NOT_APPL;
643 cfm->cfm.status = LCM_PRIM_NOK;
644 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
645 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
646 "invalid action=%d", cntrl->t.cntrl.action);
651 idx = (uint8_t)cntrl->t.cntrl.s.rgSapCntrl.spId;
652 if (idx > LRG_MAX_SAPS_PER_INST)
654 cfm->cfm.status = LCM_PRIM_NOK;
655 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
657 switch(cntrl->t.cntrl.action)
660 memset(&rgSchCb[inst].rgrSap[idx], 0, sizeof(RgSchUpSapCb));
661 rgSchCb[inst].rgrSap[idx].sapSta.sapState = LRG_NOT_CFG;
662 cfm->cfm.status = LCM_PRIM_OK;
663 cfm->cfm.reason = LCM_REASON_NOT_APPL;
666 cfm->cfm.status = LCM_PRIM_NOK;
667 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
668 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
669 "invalid action=%d", cntrl->t.cntrl.action);
674 idx = (uint8_t)cntrl->t.cntrl.s.rgSapCntrl.spId;
675 if (idx > LRG_MAX_SAPS_PER_INST)
677 cfm->cfm.status = LCM_PRIM_NOK;
678 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
680 switch(cntrl->t.cntrl.action)
683 memset(&rgSchCb[inst].rgmSap[idx], 0, sizeof(RgSchUpSapCb));
684 rgSchCb[inst].rgmSap[idx].sapSta.sapState = LRG_NOT_CFG;
685 cfm->cfm.status = LCM_PRIM_OK;
686 cfm->cfm.reason = LCM_REASON_NOT_APPL;
689 cfm->cfm.status = LCM_PRIM_NOK;
690 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
691 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
692 "invalid action=%d", cntrl->t.cntrl.action);
698 /* Would never come here. */
701 RgMiLrgSchCntrlCfm(cfmPst, cfm);
706 /***********************************************************
708 * Func : SchFillCfmPst
711 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
712 * and the cfm->hdr.response.
719 * File : rg_sch_lmm.c
721 **********************************************************/
731 inst = (reqPst->dstInst - SCH_INST_START);
733 cfmPst->srcEnt = ENTMAC;
734 cfmPst->srcInst = (Inst) 1;
735 cfmPst->srcProcId = rgSchCb[inst].rgSchInit.procId;
736 cfmPst->dstEnt = ENTMAC;
737 cfmPst->dstInst = (Inst) 0;
738 cfmPst->dstProcId = reqPst->srcProcId;
740 cfmPst->selector = cfm->hdr.response.selector;
741 cfmPst->region = cfm->hdr.response.mem.region;
742 cfmPst->pool = cfm->hdr.response.mem.pool;
749 * @brief Timer start handler.
753 * Function : rgSCHLmmStartTmr
755 * This function based on the input parameters starts the timer for
756 * "tmrVal" duration. As of now scheduler instance uses the timer
757 * functionality for BndReq only. Hence there is no conditional
758 * code based on "tmrEvnt".
760 * @param[in] S16 tmrEvnt, the Timer Event
761 * @param[in] uint32_t tmrVal, the Wait Time
762 * @param[in] PTR cb, Entry for which Timer expired
769 S16 tmrEvnt, /* Timer Event */
770 uint32_t tmrVal, /* Wait Time */
771 PTR cb /* Entry for which Timer Expired */
775 /* Inst dInst = inst + SCH_INST_START; */
779 /* Initialize the arg structure */
780 memset(&arg, 0, sizeof(CmTmrArg));
782 arg.tqCp = &rgSchCb[inst].tmrTqCp;
783 arg.tq = rgSchCb[inst].tmrTq;
784 arg.timers = &((RgSchLowSapCb *)cb)->tmrBlk;
787 arg.max = RGSCH_MAX_TIMER;
788 arg.evnt = RGSCH_BNDREQ_TMR;
797 * @brief Timer stop handler.
801 * Function : rgSCHLmmStopTmr
803 * This function based on the input parameters stops the timer for
804 * "tmrEvnt". As of now Scheduler instance uses the timer functionality for
805 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
806 * Once the bind happens and this timer is stopped, the timer functionality
807 * is deregistered with SSI. As there is no further use of timer processing.
809 * @param[in] S16 tmrEvnt, the Timer Event
810 * @param[in] PTR cb, Entry for which Timer expired
817 Inst inst, /* Scheduler instance */
818 S16 tmrEvnt, /* Timer Event */
819 PTR cb /* Entry for which Timer Expired */
828 for(i=0;i<RGSCH_MAX_TIMER;i++)
830 /* Search for the Timer Blocks */
831 if(((RgSchLowSapCb *)cb)->tmrBlk.tmrEvnt == tmrEvnt)
833 /* Initialize the arg structure */
834 memset(&arg, 0, sizeof(CmTmrArg));
836 arg.tqCp = &rgSchCb[inst].tmrTqCp;
837 arg.tq = rgSchCb[inst].tmrTq;
838 arg.timers = &(((RgSchLowSapCb *)cb)->tmrBlk);
840 arg.max = RGSCH_MAX_TIMER;
857 * @brief Timer Expiry handler.
861 * Function : rgSCHLmmTmrExpiry
863 * This is a callback function used as an input parameter to cmPrcTmr()
864 * to check expiry of any timer. In this function, we are only concerned
865 * about tmrEvnt=Bind timer.
867 * @param[in] PTR cb, Entry for which Timer expired
868 * @param[in] S16 tmrEvnt, the Timer Event
872 S16 rgSCHLmmTmrExpiry
874 PTR cb, /* Pointer to timer control block */
875 S16 tmrEvnt /* Timer Event */
879 RgSchLowSapCb *tfuSap = (RgSchLowSapCb *)cb;
881 Inst inst = tfuSap->cell->instIdx;
887 case RGSCH_BNDREQ_TMR:
888 tfuSap->numBndRetries++;
889 if(tfuSap->numBndRetries > RGSCH_MAX_BNDRETRY)
891 rgSCHLmmStaInd((uint8_t)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
892 (uint16_t)LCM_CATEGORY_INTERFACE, (uint16_t)LCM_EVENT_BND_FAIL,
893 (uint16_t)LCM_CAUSE_TMR_EXPIRED, (RgUstaDgn *)NULLP);
897 /* Restart the bind timer */
898 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
900 ret = rgSCHLmmStartTmr((uint8_t)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
902 (uint32_t)tfuSap->sapCfg.bndTmr.val, cb);
905 /* Send bind request */
906 //rgSCHUtlTfuBndReq((uint8_t)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
907 //tfuSap->sapCfg.suId, tfuSap->sapCfg.spId);
911 RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmTmrExpiry(): Invalid"
912 " tmrEvnt=%d", tmrEvnt);
921 * @brief Layer Manager Control Confirm generation handler
922 * for Bind Confirm reception at TFU interface.
923 * RgLiTfuBndCfm() forwards the confirmation to this
924 * function. All SAP state related handling is restricted
925 * to LMM modules, hence the cfm forwarding.
929 * Function : rgSCHLmmBndCfm
931 * This API is used by the LIM module of MAC to forward
932 * the Bind Confirm it receives over the TFU interface.
934 * @param[in] Pst *pst, Post Structure
935 * @param[in] SuId suId, Service user ID
936 * @param[in] uint8_t status, Status
942 Pst *pst, /* Post Structure */
943 SuId suId, /* Service user ID */
944 uint8_t status /* Status */
950 Inst inst = (pst->dstInst - SCH_INST_START); /* scheduler instance */
953 /* check the SAP State */
954 switch(rgSchCb[inst].tfuSap[suId].sapSta.sapState)
956 case LRG_WAIT_BNDCFM:
959 /* SAP is already bound */
965 cfmPst = rgSchCb[inst].rgSchInit.lmPst;
966 cfmPst.selector = rgSchCb[inst].genCfg.bndCfmResp[suId].response.selector;
967 cfmPst.prior = rgSchCb[inst].genCfg.bndCfmResp[suId].response.prior;
968 cfmPst.route = rgSchCb[inst].genCfg.bndCfmResp[suId].response.route;
969 cfmPst.region = rgSchCb[inst].genCfg.bndCfmResp[suId].response.mem.region;
970 cfmPst.pool = rgSchCb[inst].genCfg.bndCfmResp[suId].response.mem.pool;
972 memset(&cntrlCfm, 0, sizeof(RgMngmt));
976 case CM_BND_OK: /* status is OK */
977 /* Change SAP state to Bound */
978 rgSchCb[inst].tfuSap[suId].sapSta.sapState = LRG_BND;
979 if (rgSchCb[inst].tfuSap[suId].sapCfg.bndTmr.enb == TRUE)
981 ret = rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[suId]);
983 /* Send Control Confirm with status as OK to Layer Manager */
984 cntrlCfm.cfm.status = LCM_PRIM_OK;
985 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
986 /* Sending Status Indication to Layer Manager */
987 rgSCHLmmStaInd((uint8_t)(rgSchCb[inst].tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
988 LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_OK,
989 LCM_CAUSE_LYR_SPECIFIC, (RgUstaDgn *)NULLP);
993 /* Change SAP state to UnBound */
994 rgSchCb[inst].tfuSap[suId].sapSta.sapState = LRG_UNBND;
995 if (rgSchCb[inst].tfuSap[suId].sapCfg.bndTmr.enb == TRUE)
997 ret = rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[suId]);
999 /* Send Control Confirm with status as NOK to Layer Manager */
1000 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1001 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1004 rgSchCb[inst].tfuSap[suId].numBndRetries = 0;
1005 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1006 cntrlCfm.hdr.transId = rgSchCb[inst].genCfg.bndCfmResp[suId].transId;
1008 ret = RgMiLrgSchCntrlCfm(&cfmPst, &cntrlCfm);
1014 * @brief Layer Manager Unsolicited Status Indication generation.
1018 * Function : rgSCHLmmStaInd
1020 * This API is used by the other modules of MAC to send a unsolicited
1021 * status indication to the Layer Manager.
1023 * @param[in] uint16_t category, the Alarm category
1024 * @param[in] uint16_t event, the Alarm event
1025 * @param[in] uint16_t cause, the cause of the Alarm
1026 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1041 if(rgSchCb[inst].rgSchInit.usta == FALSE)
1045 memset(&usta, 0, sizeof(RgMngmt));
1047 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1048 usta.t.usta.cmAlarm.category = category;
1049 usta.t.usta.cmAlarm.event = event;
1050 usta.t.usta.cmAlarm.cause = cause;
1053 memcpy(&usta.t.usta.dgn, dgn, sizeof(RgUstaDgn));
1056 rgSchCb[inst].rgSchInit.lmPst.selector =
1057 rgSchCb[inst].genCfg.ustaResp.response.selector;
1058 rgSchCb[inst].rgSchInit.lmPst.prior =
1059 rgSchCb[inst].genCfg.ustaResp.response.prior;
1060 rgSchCb[inst].rgSchInit.lmPst.route =
1061 rgSchCb[inst].genCfg.ustaResp.response.route;
1062 rgSchCb[inst].rgSchInit.lmPst.region =
1063 rgSchCb[inst].genCfg.ustaResp.response.mem.region;
1064 rgSchCb[inst].rgSchInit.lmPst.pool =
1065 rgSchCb[inst].genCfg.ustaResp.response.mem.pool;
1066 usta.hdr.transId = rgSchCb[inst].genCfg.ustaResp.transId;
1068 return (RgMiLrgSchStaInd(&rgSchCb[inst].rgSchInit.lmPst, &usta));
1073 * @brief Scheduler instance timer call back function registered with SSI.
1077 * Function : schActvTmr
1079 * This function is invoked by SSI for every timer activation
1080 * period expiry. Note that SS_MT_TMR flag needs to be enabled for this
1081 * as isntId is needed.As part of SRegTmr call for scheduler instance
1082 * SS_MT_TMR flag needs to be enabled and schActvTmr needs to be given as
1088 S16 schActvTmr(Ent ent,Inst inst)
1090 Inst schInst = (inst - SCH_INST_START);
1092 /* Check if any timer in the scheduler instance has expired */
1093 cmPrcTmr(&rgSchCb[schInst].tmrTqCp,
1094 rgSchCb[schInst].tmrTq, (PFV) rgSCHLmmTmrExpiry);
1098 } /* end of schActvTmr */
1101 /**********************************************************************
1104 **********************************************************************/