replaced cmMemSet, cmMemcpy with memset and memcpy resp AND Removed TRC() traces...
[o-du/l2.git] / src / 5gnrsch / rg_sch_lmm.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18
19 /************************************************************************
20  
21      Name:     LTE-MAC layer
22   
23      Type:     C source file
24   
25      Desc:     C source code for Layer Manager Interface Module 
26   
27      File:     rg_sch_lmm.c 
28   
29 **********************************************************************/
30
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.
35 */
36
37 static const char* RLOG_MODULE_NAME="MAC";
38 static int RLOG_MODULE_ID=4096;
39 static int RLOG_FILE_ID=167;
40
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 */
51 #ifdef LTE_L2_MEAS
52 #include "rg_sch_cmn.h"    /* typedefs for Scheduler */
53 #endif
54 #include "rl_interface.h"
55 #include "rl_common.h"
56
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 */
64 #ifdef LTE_L2_MEAS
65 #include "rg_sch_cmn.x"    /* typedefs for Scheduler */
66 #endif 
67 #ifndef LTE_L2_MEAS
68 Void rgSCHCmnInit ARGS((Void));
69 #endif 
70 /* forward references */
71 extern int schActvInit(Ent entity, Inst instId, Region region, Reason reason);
72 #ifdef UNUSE_FUN
73 PRIVATE U16 rgSCHLmmSapCfg ARGS((
74    Inst           inst,
75    RgCfg          *cfg,
76    U8             sapIdx,
77    Elmnt          sapType
78 ));
79 #endif
80 PRIVATE Void rgSCHLmmShutdown ARGS((
81    Inst inst
82 ));
83
84
85 void printSchCellInfo(void)
86 {
87    U8 idx=0;
88    U8 inst=0;
89    for (idx = 0; idx < rgSchCb[inst].numSaps; idx++)
90    {
91       /* Unbind all the TFU SAP */
92       /* Free the memory held by the cell associated
93        * with this SAP */
94       if (rgSchCb[inst].tfuSap[idx].cell != NULLP)
95       {
96          RLOG1(L_INFO,"CELL %d\n", idx);
97          RLOG1(L_INFO,"NUM UEs :%d\n",rgSchCb[inst].tfuSap[idx].cell->ueLst.nmbEnt);
98       }
99    }
100 }
101
102 /**
103  * @brief SAP Configuration Handler. 
104  *
105  * @details
106  *
107  *     Function : rgSCHLmmSapCfg
108  *     
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.
113  *     
114  *  @param[in]  RgCfg *cfg, the Configuaration information 
115  *  @return  U16
116  *      -# LCM_REASON_GENCFG_NOT_DONE
117  *      -# LCM_REASON_INVALID_SAP
118  *      -# LCM_REASON_NOT_APPL
119  **/
120 #ifdef UNUSE_FUN
121 #ifdef ANSI
122 PRIVATE U16 rgSCHLmmSapCfg
123 (
124 Inst  dInst,
125 RgCfg *cfg,            /* Configuaration information */
126 U8    sapIdx,          /* SAP index */
127 Elmnt sapType             /* SAP Type */
128 )
129 #else
130 PRIVATE U16 rgSCHLmmSapCfg(dInst, cfg, sapIdx, sapType)
131 Inst  dInst;
132 RgCfg *cfg;            /* Configuaration information */
133 U8    sapIdx;          /* SAP index */
134 Elmnt sapType;            /* SAP Type */
135 #endif
136 {
137    U16                  ret = LCM_REASON_NOT_APPL;
138    RgSchLowSapCfgInfo   *lowSapCfg = NULLP;
139    RgSchUpSapCfgInfo    *upSapCfg = NULLP;
140    Inst  inst = (dInst - SCH_INST_START);
141
142    /* Check if Gen Config has been done */
143
144    switch(sapType)
145    {   
146       case STRGRSAP:
147 #ifndef CL_MAC_LWLC
148          if ((cfg->s.schInstCfg.rgrSap[sapIdx].selector != ODU_SELECTOR_TC) &&
149              (cfg->s.schInstCfg.rgrSap[sapIdx].selector != ODU_SELECTOR_LC))
150          {
151             ret = LCM_REASON_INVALID_PAR_VAL;
152             RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
153                " Selector value for RGR.");
154             break;
155          }
156 #endif
157          if(rgSchCb[inst].rgrSap[sapIdx].sapSta.sapState == LRG_NOT_CFG)
158          { 
159             rgSchCb[inst].rgrSap[sapIdx].sapSta.sapState = LRG_UNBND;
160          }
161          upSapCfg = &rgSchCb[inst].rgrSap[sapIdx].sapCfg;
162
163          upSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.rgrSap[sapIdx].ent;
164          upSapCfg->sapPst.dstInst = cfg->s.schInstCfg.rgrSap[sapIdx].inst;
165          upSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.rgrSap[sapIdx].procId;
166          upSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
167          upSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
168          SCH_INST_START;
169          upSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
170          upSapCfg->sapPst.region = cfg->s.schInstCfg.rgrSap[sapIdx].mem.region;
171          upSapCfg->sapPst.pool = cfg->s.schInstCfg.rgrSap[sapIdx].mem.pool;
172          upSapCfg->sapPst.selector = cfg->s.schInstCfg.rgrSap[sapIdx].selector;
173          upSapCfg->sapPst.route = cfg->s.schInstCfg.rgrSap[sapIdx].route;
174          upSapCfg->sapPst.intfVer = 0; 
175          upSapCfg->sapPst.event = 0; 
176          upSapCfg->sapPst.prior = cfg->s.schInstCfg.rgrSap[sapIdx].prior;
177          upSapCfg->suId = cfg->s.schInstCfg.rgrSap[sapIdx].suId;
178          upSapCfg->spId = cfg->s.schInstCfg.rgrSap[sapIdx].spId;
179          break;
180       case STTFUSAP:
181 #ifndef CL_MAC_LWLC
182          if ((cfg->s.schInstCfg.tfuSap[sapIdx].selector != ODU_SELECTOR_TC) &&
183              (cfg->s.schInstCfg.tfuSap[sapIdx].selector != ODU_SELECTOR_LC))
184          {
185             ret = LCM_REASON_INVALID_PAR_VAL;
186             RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
187                      " Selector value for TFU.");
188             break;
189          }
190 #endif
191          if (rgSchCb[inst].tfuSap[sapIdx].sapSta.sapState == LRG_NOT_CFG) 
192          { 
193             rgSchCb[inst].tfuSap[sapIdx].sapSta.sapState = LRG_UNBND;
194          }
195          /* Initialize the  sap timer */
196          cmInitTimers(&(rgSchCb[inst].tfuSap[sapIdx].tmrBlk), 1);
197          lowSapCfg = &rgSchCb[inst].tfuSap[sapIdx].sapCfg;
198
199          lowSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.tfuSap[sapIdx].ent;
200          lowSapCfg->sapPst.dstInst = cfg->s.schInstCfg.tfuSap[sapIdx].inst;
201          lowSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.tfuSap[sapIdx].procId;
202          lowSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
203          lowSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
204          SCH_INST_START;
205          lowSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
206          lowSapCfg->sapPst.region = cfg->s.schInstCfg.tfuSap[sapIdx].mem.region;
207          lowSapCfg->sapPst.pool = cfg->s.schInstCfg.tfuSap[sapIdx].mem.pool;
208          lowSapCfg->sapPst.selector = cfg->s.schInstCfg.tfuSap[sapIdx].selector;
209          lowSapCfg->sapPst.route = cfg->s.schInstCfg.tfuSap[sapIdx].route;
210          lowSapCfg->sapPst.intfVer = 0; 
211           lowSapCfg->sapPst.event = 0; 
212          lowSapCfg->sapPst.prior = cfg->s.schInstCfg.tfuSap[sapIdx].prior;
213          lowSapCfg->suId = cfg->s.schInstCfg.tfuSap[sapIdx].suId;
214          lowSapCfg->spId = cfg->s.schInstCfg.tfuSap[sapIdx].spId;
215          memcpy(&lowSapCfg->bndTmr, 
216                   &cfg->s.schInstCfg.tfuSap[sapIdx].bndTmr,
217                   sizeof(TmrCfg));
218          break;
219       case STRGMSAP:
220 #ifndef RGM_LWLC
221          if ((cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_LWLC) &&
222              (cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_LC) &&
223              (cfg->s.schInstCfg.rgmSap[sapIdx].selector != RGM_SEL_TC))
224          {
225             ret = LCM_REASON_INVALID_PAR_VAL;
226             RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
227                      " Selector value for RGM.");
228             break;
229          }
230 #endif
231          if (rgSchCb[inst].rgmSap[sapIdx].sapSta.sapState == LRG_NOT_CFG) 
232          { 
233             rgSchCb[inst].rgmSap[sapIdx].sapSta.sapState = LRG_UNBND;
234          }
235          upSapCfg = &rgSchCb[inst].rgmSap[sapIdx].sapCfg;
236          upSapCfg->sapPst.dstEnt = cfg->s.schInstCfg.rgmSap[sapIdx].ent;
237          upSapCfg->sapPst.dstInst = cfg->s.schInstCfg.rgmSap[sapIdx].inst;
238          upSapCfg->sapPst.dstProcId = cfg->s.schInstCfg.rgmSap[sapIdx].procId;
239          upSapCfg->sapPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
240          upSapCfg->sapPst.srcInst = rgSchCb[inst].rgSchInit.inst +
241          SCH_INST_START;
242          upSapCfg->sapPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
243          upSapCfg->sapPst.region = cfg->s.schInstCfg.rgmSap[sapIdx].mem.region;
244          upSapCfg->sapPst.pool = cfg->s.schInstCfg.rgmSap[sapIdx].mem.pool;
245          upSapCfg->sapPst.selector = cfg->s.schInstCfg.rgmSap[sapIdx].selector;
246          upSapCfg->sapPst.route = cfg->s.schInstCfg.rgmSap[sapIdx].route;
247          upSapCfg->sapPst.intfVer = 0; 
248          upSapCfg->sapPst.event = 0; 
249          upSapCfg->sapPst.prior = cfg->s.schInstCfg.rgmSap[sapIdx].prior;
250          upSapCfg->suId = cfg->s.schInstCfg.rgmSap[sapIdx].suId;
251          upSapCfg->spId = cfg->s.schInstCfg.rgmSap[sapIdx].spId;
252
253          break;
254       default:
255          /* would never reach here */
256          break;
257    }
258    return (ret);
259 }
260 #endif
261 \f
262 /***********************************************************
263  *
264  *     Func : rgSCHLmmShutdown
265  *        
266  *
267  *     Desc : Handles the scheduler instance shutdown request. Calls 
268  *     rgSCHCfgFreeCellCb(RgSchCellCb*) to handle each cellCb deallocation.
269  *            
270  *
271  *     Ret  : Void
272  *
273  *     Notes: 
274  *
275  *     File : rg_sch_lmm.c 
276  *
277  **********************************************************/
278 #ifdef ANSI
279 PRIVATE Void rgSCHLmmShutdown
280 (
281 Inst inst
282 )
283 #else
284 PRIVATE Void rgSCHLmmShutdown(inst)
285 Inst inst;
286 #endif
287 {
288    Inst          dInst = inst + SCH_INST_START;
289    U8            idx;
290 #ifdef LTE_L2_MEAS
291    CmLList       *lnk = NULLP;
292    RgSchCb       *instCb =  &rgSchCb[inst];
293    RgSchCellCb   *cell = NULLP;
294    RgSchL2MeasCb *measCb;
295    U8            ulAllocIdx;
296    RgSchCmnUlCell *cellUl;
297    RgSchClcBoRpt  *bo = NULL;
298 #endif
299
300 #ifdef LTE_L2_MEAS
301    for (idx = 0; idx < instCb->numSaps; idx++)
302    {
303      /* got the cell break the loop */
304      cell = instCb->rgrSap[idx].cell;
305      if(cell != NULLP)
306      {
307         /* Free the memory held up by  ulAllocInfo */
308         cellUl = RG_SCH_CMN_GET_UL_CELL(cell);
309 #ifdef LTE_TDD
310         for(ulAllocIdx = 0; ulAllocIdx < RGSCH_SF_ALLOC_SIZE; ulAllocIdx++)
311 #else
312         for(ulAllocIdx = 0; ulAllocIdx < RGSCH_NUM_SUB_FRAMES; ulAllocIdx++)
313 #endif
314         {
315            if(cell->sfAllocArr[ulAllocIdx].ulUeInfo.ulAllocInfo != NULLP)
316            {
317              /* ccpu00117052 - MOD - Passing double pointer
318              for proper NULLP assignment*/
319              rgSCHUtlFreeSBuf(cell->instIdx, 
320                     (Data **)(&(cell->sfAllocArr[ulAllocIdx].ulUeInfo.\
321                                 ulAllocInfo)),
322                     cellUl->maxAllocPerUlSf * sizeof(RgInfUeUlAlloc));
323            }
324         }
325         /* Free the memory allocated to measCb */
326         lnk = cell->l2mList.first;
327         while(lnk != NULLP)
328         {
329            measCb = (RgSchL2MeasCb *)lnk->node;
330            cmLListDelFrm(&cell->l2mList, lnk);
331            lnk = lnk->next;
332              /* ccpu00117052 - MOD - Passing double pointer
333              for proper NULLP assignment*/
334            rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&measCb,\
335                           sizeof(RgSchL2MeasCb));
336         }
337
338         /* Free mem if any present for boLst for common channels */
339         for(idx = 0; idx < RGSCH_MAX_CMN_LC_CB; idx++)
340         {
341            lnk = (CmLList *)cell->cmnLcCb[idx].boLst.first;
342            while (lnk)
343            {
344               bo = (RgSchClcBoRpt *)(lnk->node);
345               lnk = lnk->next;
346               cmLListDelFrm(&cell->cmnLcCb[idx].boLst, &bo->boLstEnt);
347               rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&bo, sizeof(RgSchClcBoRpt));
348            }
349         }
350      }
351    }
352 #endif
353
354 #ifdef LTE_ADV
355    rgSCHLaaDeInitEnbCb(&rgSchCb[inst]);
356 #endif
357    for (idx = 0; idx < rgSchCb[inst].numSaps; idx++)
358    {
359       /* Unbind all the TFU SAP */
360       if(rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_WAIT_BNDCFM)
361       {
362          rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg, LRG_UNBND);
363          if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
364          {
365             rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[idx]); 
366          }
367          rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
368       }
369       if(rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND)
370       {
371          rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg, LRG_UNBND);
372          rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
373       }
374       /* Free the memory held by the cell associated with this SAP */
375       if (rgSchCb[inst].tfuSap[idx].cell != NULLP)
376          rgSCHCfgFreeCellCb(rgSchCb[inst].tfuSap[idx].cell);
377       rgSchCb[inst].tfuSap[idx].cell = NULLP;
378    }
379    /* Free the memory held by the scheduler instance */
380    /* Deallocate RGR saps */
381    SPutSBuf(rgSchCb[inst].rgSchInit.region,
382                 rgSchCb[inst].rgSchInit.pool,
383                 (Data *)rgSchCb[inst].rgrSap,
384                 (sizeof(RgSchUpSapCb) * rgSchCb[inst].numSaps));
385    rgSchCb[inst].rgrSap = NULLP;
386    /* Deallocate RGM saps */
387    SPutSBuf(rgSchCb[inst].rgSchInit.region,
388                 rgSchCb[inst].rgSchInit.pool,
389                 (Data *)rgSchCb[inst].rgmSap,
390                 (sizeof(RgSchUpSapCb) * rgSchCb[inst].numSaps));
391    rgSchCb[inst].rgmSap = NULLP;
392
393    /* Deallocate TFU saps */
394    SPutSBuf(rgSchCb[inst].rgSchInit.region,
395                 rgSchCb[inst].rgSchInit.pool,
396                 (Data *)rgSchCb[inst].tfuSap,
397                 (sizeof(RgSchLowSapCb) * rgSchCb[inst].numSaps));
398    rgSchCb[inst].tfuSap = NULLP;
399
400    /* Deallocate bndCfmResponses */
401    SPutSBuf(rgSchCb[inst].rgSchInit.region,
402                 rgSchCb[inst].rgSchInit.pool,
403                 (Data *)rgSchCb[inst].genCfg.bndCfmResp,
404                 (sizeof(RgSchLmResponse) * rgSchCb[inst].numSaps));
405    rgSchCb[inst].genCfg.bndCfmResp = NULLP;
406    /* De-register the Timer Service */
407    (Void) SDeregTmrMt(rgSchCb[inst].rgSchInit.ent, dInst,
408                      (S16)rgSchCb[inst].genCfg.tmrRes, schActvTmr); 
409
410    /* call back the task initialization function to intialize
411     * the global rgSchCb[inst] Struct */
412    schActvInit(rgSchCb[inst].rgSchInit.ent, dInst, rgSchCb[inst].rgSchInit.region, 
413               rgSchCb[inst].rgSchInit.reason);
414    
415    /* Set Config done in TskInit */
416    rgSchCb[inst].rgSchInit.cfgDone = FALSE;
417
418    RETVOID;
419 }
420
421 \f
422 /***********************************************************
423  *
424  *     Func : rgSCHLmmGenCntrl 
425  *        
426  *
427  *     Desc : Processes the LM control request for STGEN elmnt.
428  *            
429  *
430  *     Ret  : Void
431  *
432  *     Notes: 
433  *
434  *     File : rg_sch_lmm.c 
435  *
436  **********************************************************/
437 #ifdef ANSI
438 Void rgSCHLmmGenCntrl 
439 (
440 RgMngmt       *cntrl,
441 RgMngmt       *cfm,
442 Pst           *cfmPst
443 )
444 #else
445 Void rgSCHLmmGenCntrl(cntrl, cfm, cfmPst)
446 RgMngmt       *cntrl;
447 RgMngmt       *cfm;
448 Pst           *cfmPst;
449 #endif
450 {
451    Inst      inst = (cfmPst->srcInst - SCH_INST_START); /* Scheduler instance ID */
452
453    cfm->cfm.status = LCM_PRIM_OK;
454    cfm->cfm.reason = LCM_REASON_NOT_APPL;
455    
456
457    switch(cntrl->t.cntrl.action)
458    {
459       case AENA:
460          /* Action is Enable */
461          switch(cntrl->t.cntrl.subAction)
462          {
463             case SAUSTA:   
464             /* Enable Unsolicited Status (alarms) */
465                rgSchCb[inst].rgSchInit.usta = TRUE;
466                /*Store the response and TransId for sending the Alarms */
467                memcpy(&rgSchCb[inst].genCfg.ustaResp.response, 
468                &cntrl->hdr.response, sizeof(Resp));
469                rgSchCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
470                break;
471             case SADBG:
472             /* Enable Debug Printing */
473 #ifdef DEBUGP
474                rgSchCb[inst].rgSchInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
475 #endif
476                break;
477 #ifdef PHY_ERROR_LOGING
478             case SAELMNT:
479                {
480                   rgSchUlAllocCntr.mcs = cntrl->t.cntrl.s.rgSchUlAllocCntrl.mcs;
481                   rgSchUlAllocCntr.numOfRb = cntrl->t.cntrl.s.rgSchUlAllocCntrl.numOfRb;
482                   rgSchUlAllocCntr.rbStart = cntrl->t.cntrl.s.rgSchUlAllocCntrl.rbStart;
483                   rgSchUlAllocCntr.testStart = cntrl->t.cntrl.s.rgSchUlAllocCntrl.testStart;
484                   rgSchUlAllocCntr.enaLog = cntrl->t.cntrl.s.rgSchUlAllocCntrl.enaLog;
485                   rgSchUlAllocCntr.logTime = cntrl->t.cntrl.s.rgSchUlAllocCntrl.logTime;
486                   rgSchUlAllocCntr.crcOk = 0;
487                   rgSchUlAllocCntr.crcErr = 0;
488                   rgSchUlAllocCntr.numUlPackets = 0;
489                   rgSchUlAllocCntr.numPrach = 0;
490                   rgSchUlAllocCntr.taZero = 0;
491 #ifdef MAC_SCH_STATS
492                   /* Reset
493                    * L2
494                    * statistics
495                    * */
496                   memset(&hqRetxStats, 0, sizeof(RgSchHqRetxStats));
497                   memset(&hqFailStats, 0, sizeof(RgSchNackAckStats));
498 #endif
499                   break;
500                }
501 #endif
502             default:
503                cfm->cfm.status = LCM_PRIM_NOK;
504                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
505                RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl(): "
506                   "invalid subaction=%d", cntrl->t.cntrl.subAction);
507                break;
508          }
509          break;
510       case ADISIMM:
511          /* Action is Diable immidiately */
512          switch(cntrl->t.cntrl.subAction)
513          {
514             case SAUSTA:
515             /* Disable Unsolicited Status (alarms) */
516                rgSchCb[inst].rgSchInit.usta = FALSE;
517                break;
518             case SADBG:
519             /* Disable Debug Printing */
520 #ifdef DEBUGP
521                rgSchCb[inst].rgSchInit.dbgMask &=\
522                           ~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
523 #endif
524                break;
525
526             default:
527                cfm->cfm.status = LCM_PRIM_NOK;
528                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
529                RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl():"
530                  " invalid subaction=%d", cntrl->t.cntrl.subAction);
531                break;
532          }
533          break;
534       case ASHUTDOWN:
535          /* Free all the memory dynamically allocated by MAC */
536          rgSCHLmmShutdown(inst);
537          break;
538       default:
539          cfm->cfm.status = LCM_PRIM_NOK;
540          cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
541          RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmGenCntrl(): invalid"
542           " action=%d", cntrl->t.cntrl.action);
543          break;
544    }
545    RgMiLrgSchCntrlCfm(cfmPst, cfm);
546    RETVOID;
547 }
548
549 \f
550 /***********************************************************
551  *
552  *     Func : rgSCHLmmSapCntrl 
553  *        
554  *
555  *     Desc : Processes the LM control request for STxxxSAP elmnt.
556  *            
557  *
558  *     Ret  : Void
559  *
560  *     Notes: 
561  *
562  *     File : rg_sch_lmm.c 
563  *
564  **********************************************************/
565 #ifdef ANSI
566 Void rgSCHLmmSapCntrl 
567 (
568 RgMngmt       *cntrl,
569 RgMngmt       *cfm,
570 Pst           *cfmPst
571 )
572 #else
573 Void rgSCHLmmSapCntrl(cntrl, cfm, cfmPst)
574 RgMngmt       *cntrl;
575 RgMngmt       *cfm;
576 Pst           *cfmPst;
577 #endif
578 {
579    U8       idx;
580
581    /* TODO Pass InstId instead of using InstId from cfmPst */
582    Inst      inst = (cfmPst->srcInst - SCH_INST_START); /* Scheduler instance Id */
583
584    /* Only TFU SAP can be controlled by LM */
585    switch(cntrl->hdr.elmId.elmnt)
586    {
587       case STTFUSAP:
588          idx = (U8)cntrl->t.cntrl.s.rgSapCntrl.suId;
589          if (idx > LRG_MAX_SAPS_PER_INST)
590          {
591             cfm->cfm.status = LCM_PRIM_NOK;
592             cfm->cfm.reason = LCM_REASON_INVALID_SAP;
593          }
594          switch(cntrl->t.cntrl.action)
595          {
596             case ABND:
597                /* Bind Enable Request */
598                if ((rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_NOT_CFG) ||
599                    (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND))
600                {
601                   cfm->cfm.status = LCM_PRIM_NOK;
602                   cfm->cfm.reason = LCM_REASON_INVALID_SAP;
603                }
604                else
605                {
606                   if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
607                   {
608                      rgSCHLmmStartTmr(inst, RGSCH_BNDREQ_TMR,
609                                   rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.val, 
610                                   (PTR)&rgSchCb[inst].tfuSap[idx]);
611                   }
612                   /* Change SAP state */
613                   rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_WAIT_BNDCFM;
614                   rgSchCb[inst].tfuSap[idx].numBndRetries++;
615                   /* Store the response and TransId for sending 
616                    * the Control confirm */
617                   memcpy(&rgSchCb[inst].genCfg.bndCfmResp[idx].response,
618                            &cntrl->hdr.response, sizeof(Resp));
619                   rgSchCb[inst].genCfg.bndCfmResp[idx].transId = 
620                                                 cntrl->hdr.transId;
621                   
622                   cfm->cfm.status = LCM_PRIM_OK_NDONE;
623                   cfm->cfm.reason = LCM_REASON_NOT_APPL;
624
625                   /* Sending Control Confirm before sending Bind
626                    * Request to TFU  */
627                   RgMiLrgSchCntrlCfm(cfmPst, cfm);
628                   
629                   rgSCHUtlTfuBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg.suId, 
630                                  rgSchCb[inst].tfuSap[idx].sapCfg.spId);
631                  RETVOID; 
632                }
633                break;
634             case AUBND:
635             /* Unbind request */
636
637                /* Check if the SAP is configured */
638                if( (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_NOT_CFG) ||
639                      (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_UNBND))
640                {
641                   cfm->cfm.status = LCM_PRIM_NOK;
642                   cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
643                }
644                else
645                {
646                   rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg,
647                                   TFU_UBNDREQ_MNGMT);
648                   if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
649                   {
650                      rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, 
651                                        (PTR)&rgSchCb[inst].tfuSap[idx]);
652                   }
653                   /* Change SAP state */
654                   rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_UNBND;
655                   cfm->cfm.status = LCM_PRIM_OK;
656                   cfm->cfm.reason = LCM_REASON_NOT_APPL;
657                }
658                break;
659             case ADEL:
660                /* Delete SAP, does initialization of SAP */
661                if ((rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_WAIT_BNDCFM) ||
662                    (rgSchCb[inst].tfuSap[idx].sapSta.sapState == LRG_BND))
663                {
664                   rgSCHUtlTfuUBndReq(inst, rgSchCb[inst].tfuSap[idx].sapCfg,
665                                   TFU_UBNDREQ_MNGMT);
666                   if (rgSchCb[inst].tfuSap[idx].sapCfg.bndTmr.enb == TRUE)
667                   {
668                      rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR,
669                                      (PTR)&rgSchCb[inst].tfuSap[idx]);
670                   }
671                }
672                memset(&rgSchCb[inst].tfuSap[idx], 0, sizeof(RgSchLowSapCb));
673                rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_NOT_CFG;
674                cfm->cfm.status = LCM_PRIM_OK;
675                cfm->cfm.reason = LCM_REASON_NOT_APPL;
676                break;
677             default:
678                cfm->cfm.status = LCM_PRIM_NOK;
679                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
680                RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
681                   "invalid action=%d", cntrl->t.cntrl.action);
682                break;
683          }
684          break;
685       case STRGRSAP:
686          idx = (U8)cntrl->t.cntrl.s.rgSapCntrl.spId;
687          if (idx > LRG_MAX_SAPS_PER_INST)
688          {
689             cfm->cfm.status = LCM_PRIM_NOK;
690             cfm->cfm.reason = LCM_REASON_INVALID_SAP;
691          }
692          switch(cntrl->t.cntrl.action)
693          {
694             case ADEL:
695                memset(&rgSchCb[inst].rgrSap[idx], 0, sizeof(RgSchUpSapCb));
696                rgSchCb[inst].rgrSap[idx].sapSta.sapState = LRG_NOT_CFG;
697                cfm->cfm.status = LCM_PRIM_OK;
698                cfm->cfm.reason = LCM_REASON_NOT_APPL;
699                break;
700             default:
701                cfm->cfm.status = LCM_PRIM_NOK;
702                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
703                RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
704                      "invalid action=%d", cntrl->t.cntrl.action);
705                break;
706          }
707          break;
708       case STRGMSAP:
709          idx = (U8)cntrl->t.cntrl.s.rgSapCntrl.spId;
710          if (idx > LRG_MAX_SAPS_PER_INST)
711          {
712             cfm->cfm.status = LCM_PRIM_NOK;
713             cfm->cfm.reason = LCM_REASON_INVALID_SAP;
714          }
715          switch(cntrl->t.cntrl.action)
716          {
717             case ADEL:
718                memset(&rgSchCb[inst].rgmSap[idx], 0, sizeof(RgSchUpSapCb));
719                rgSchCb[inst].rgmSap[idx].sapSta.sapState = LRG_NOT_CFG;
720                cfm->cfm.status = LCM_PRIM_OK;
721                cfm->cfm.reason = LCM_REASON_NOT_APPL;
722                break;
723             default:
724                cfm->cfm.status = LCM_PRIM_NOK;
725                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
726                RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCntrl(): "
727                      "invalid action=%d", cntrl->t.cntrl.action);
728                break;
729          }
730          break;
731
732        default:
733          /* Would never come here. */
734          RETVOID;
735    }
736    RgMiLrgSchCntrlCfm(cfmPst, cfm);
737    RETVOID;
738 }
739
740 \f
741 /***********************************************************
742  *
743  *     Func : SchFillCfmPst 
744  *        
745  *
746  *     Desc : Fills the Confirmation Post Structure cfmPst using the reqPst 
747  *            and the cfm->hdr.response.
748  *            
749  *
750  *     Ret  : Void
751  *
752  *     Notes: 
753  *
754  *     File : rg_sch_lmm.c 
755  *
756  **********************************************************/
757 #ifdef ANSI
758 Void SchFillCfmPst
759 (
760 Pst           *reqPst,
761 Pst           *cfmPst,
762 RgMngmt       *cfm
763 )
764 #else
765 Void SchFillCfmPst(reqPst, cfmPst, cfm)
766 Pst           *reqPst;
767 Pst           *cfmPst;
768 RgMngmt       *cfm;
769 #endif
770 {
771    Inst inst;
772
773    inst = (reqPst->dstInst - SCH_INST_START);
774
775    cfmPst->srcEnt    = ENTMAC;
776    cfmPst->srcInst   = (Inst) 1;
777    cfmPst->srcProcId = rgSchCb[inst].rgSchInit.procId;
778    cfmPst->dstEnt    = ENTMAC;
779    cfmPst->dstInst   = (Inst) 0;
780    cfmPst->dstProcId = reqPst->srcProcId;
781
782    cfmPst->selector  = cfm->hdr.response.selector;
783    cfmPst->region    = cfm->hdr.response.mem.region;
784    cfmPst->pool      = cfm->hdr.response.mem.pool;
785
786    RETVOID;
787 }
788
789 \f
790 /**
791  * @brief Timer start handler. 
792  *
793  * @details
794  *
795  *     Function : rgSCHLmmStartTmr
796  *     
797  *     This function based on the input parameters starts the timer for 
798  *     "tmrVal" duration. As of now scheduler instance uses the timer 
799  *     functionality for BndReq only. Hence there is no conditional
800  *     code based on "tmrEvnt".
801  *     
802  *  @param[in]  S16   tmrEvnt, the Timer Event    
803  *  @param[in]  U32   tmrVal,  the Wait Time
804  *  @param[in]  PTR   cb,  Entry for which Timer expired
805  *  @return  S16
806  *      -# ROK
807  **/
808 #ifdef ANSI
809 S16 rgSCHLmmStartTmr
810 (
811 Inst               inst,
812 S16                tmrEvnt,            /* Timer Event */
813 U32                tmrVal,             /* Wait Time */
814 PTR                cb                  /* Entry for which Timer Expired */
815 )
816 #else
817 S16 rgSCHLmmStartTmr(inst, tmrEvnt, tmrVal, cb)
818 Inst               inst;             /* scheduler instance ID */
819 S16                tmrEvnt;            /* Timer Event */
820 U32                tmrVal;             /* Wait Time */
821 PTR                cb;                 /* Entry for which Timer Expired */
822 #endif
823 {
824    CmTmrArg    arg;
825 /*   Inst        dInst = inst + SCH_INST_START; */
826
827    UNUSED(tmrEvnt);
828
829    /* Initialize the arg structure */
830    memset(&arg, 0, sizeof(CmTmrArg));
831
832    arg.tqCp = &rgSchCb[inst].tmrTqCp;
833    arg.tq = rgSchCb[inst].tmrTq;
834    arg.timers = &((RgSchLowSapCb *)cb)->tmrBlk;
835    arg.cb = cb;
836    arg.tNum = 0;
837    arg.max = RGSCH_MAX_TIMER;
838    arg.evnt = RGSCH_BNDREQ_TMR;
839    arg.wait = tmrVal;      
840    cmPlcCbTq(&arg);
841
842    return ROK;
843 }
844
845 \f
846 /**
847  * @brief Timer stop handler. 
848  *
849  * @details
850  *
851  *     Function : rgSCHLmmStopTmr
852  *     
853  *     This function based on the input parameters stops the timer for 
854  *     "tmrEvnt". As of now Scheduler instance uses the timer functionality for
855  *     BndReq only. Hence there is no conditional code based on "tmrEvnt".
856  *     Once the bind happens and this timer is stopped, the timer functionality
857  *     is deregistered with SSI. As there is no further use of timer processing.
858  *     
859  *  @param[in]  S16   tmrEvnt, the Timer Event    
860  *  @param[in]  PTR   cb,  Entry for which Timer expired
861  *  @return  S16
862  *      -# ROK
863  *      -# RFAILED
864  **/
865 #ifdef ANSI
866 S16 rgSCHLmmStopTmr
867 (
868 Inst               inst,             /* Scheduler instance */
869 S16                tmrEvnt,            /* Timer Event */
870 PTR                cb                  /* Entry for which Timer Expired */
871 )
872 #else
873 S16 rgSCHLmmStopTmr(inst, tmrEvnt, cb)
874 Inst               inst;             /* Scheduler instance */
875 S16                tmrEvnt;            /* Timer Event */
876 PTR                cb;                 /* Entry for which Timer Expired */
877 #endif
878 {
879    CmTmrArg   arg;
880    U8         i;
881    S16        ret; 
882
883    ret = RFAILED;
884
885    for(i=0;i<RGSCH_MAX_TIMER;i++)
886    {
887       /* Search for the Timer Blocks */
888       if(((RgSchLowSapCb *)cb)->tmrBlk.tmrEvnt == tmrEvnt)
889       {
890          /* Initialize the arg structure */
891          memset(&arg, 0, sizeof(CmTmrArg));
892
893          arg.tqCp = &rgSchCb[inst].tmrTqCp;
894          arg.tq = rgSchCb[inst].tmrTq;
895          arg.timers = &(((RgSchLowSapCb *)cb)->tmrBlk);
896          arg.cb = cb;
897          arg.max = RGSCH_MAX_TIMER;
898          arg.evnt = tmrEvnt;
899
900          arg.tNum = i;   
901          cmRmvCbTq(&arg);
902          ret = ROK;
903          break;
904       }
905
906    }
907
908
909    return (ret);
910 }
911
912 \f
913 /**
914  * @brief Timer Expiry handler. 
915  *
916  * @details
917  *
918  *     Function : rgSCHLmmTmrExpiry
919  *     
920  *     This is a callback function used as an input parameter to cmPrcTmr()
921  *     to check expiry of any timer. In this function, we are only concerned
922  *     about tmrEvnt=Bind timer.
923  *     
924  *  @param[in]  PTR   cb,  Entry for which Timer expired
925  *  @param[in]  S16   tmrEvnt, the Timer Event    
926  *  @return  S16
927  *      -# ROK
928  **/
929 #ifdef ANSI
930 S16 rgSCHLmmTmrExpiry
931 (
932 PTR cb,               /* Pointer to timer control block */
933 S16 tmrEvnt           /* Timer Event */
934 )
935 #else
936 S16 rgSCHLmmTmrExpiry(cb,tmrEvnt)
937 PTR cb;               /* Pointer to timer control block */
938 S16 tmrEvnt;          /* Timer Event */
939 #endif
940 {
941    S16           ret = ROK;
942    RgSchLowSapCb *tfuSap = (RgSchLowSapCb *)cb;
943 #ifdef DEBUGP
944    Inst          inst = tfuSap->cell->instIdx;
945 #endif
946
947    
948    switch(tmrEvnt)
949    {
950       case RGSCH_BNDREQ_TMR:
951          tfuSap->numBndRetries++;
952          if(tfuSap->numBndRetries > RGSCH_MAX_BNDRETRY)
953          {
954             rgSCHLmmStaInd((U8)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
955                            (U16)LCM_CATEGORY_INTERFACE, (U16)LCM_EVENT_BND_FAIL,
956                            (U16)LCM_CAUSE_TMR_EXPIRED, (RgUstaDgn *)NULLP);
957          }
958          else
959          {
960             /* Restart the bind timer */
961             if (tfuSap->sapCfg.bndTmr.enb == TRUE)
962             {
963                ret = rgSCHLmmStartTmr((U8)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
964                                   RGSCH_BNDREQ_TMR, 
965                                  (U32)tfuSap->sapCfg.bndTmr.val, cb);
966             }
967
968             /* Send bind request */
969             rgSCHUtlTfuBndReq((U8)(tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START), 
970             tfuSap->sapCfg.suId, tfuSap->sapCfg.spId);
971          }
972          break;
973       default:
974          RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "rgSCHLmmTmrExpiry(): Invalid"
975                  " tmrEvnt=%d", tmrEvnt);
976          ret = RFAILED;
977          break;
978    }
979    return (ret);
980 }
981
982 \f
983 /**
984  * @brief Layer Manager Control Confirm generation handler
985  *        for Bind Confirm reception at TFU interface.
986  *        RgLiTfuBndCfm() forwards the confirmation to this 
987  *        function. All SAP state related handling is restricted
988  *        to LMM modules, hence the cfm forwarding.
989  *
990  * @details
991  *
992  *     Function : rgSCHLmmBndCfm 
993  *     
994  *     This API is used by the LIM module of MAC to forward
995  *     the Bind Confirm it receives over the TFU interface.
996  *     
997  *  @param[in]   Pst *pst, Post Structure
998  *  @param[in]   SuId suId, Service user ID
999  *  @param[in]   U8 status, Status
1000  *  @return  S16
1001  *      -# ROK
1002  **/
1003 #ifdef ANSI
1004 S16 rgSCHLmmBndCfm
1005 (
1006 Pst *pst,               /* Post Structure */
1007 SuId suId,              /* Service user ID */
1008 U8 status               /* Status */
1009 )
1010 #else
1011 S16 rgSCHLmmBndCfm(pst,suId,status)
1012 Pst *pst;               /* Post Structure */
1013 SuId suId;              /* Service user Id */
1014 U8 status;              /* Status */
1015 #endif
1016 {
1017    S16       ret = ROK;
1018    RgMngmt   cntrlCfm;
1019    Pst       cfmPst;
1020    Inst      inst = (pst->dstInst - SCH_INST_START); /* scheduler instance */
1021
1022
1023    /* check the SAP State */
1024    switch(rgSchCb[inst].tfuSap[suId].sapSta.sapState)
1025    {
1026       case LRG_WAIT_BNDCFM:
1027          break;
1028       case LRG_BND:
1029          /* SAP is already bound */
1030          return ROK;
1031       default:
1032          return RFAILED;
1033    }
1034
1035    cfmPst = rgSchCb[inst].rgSchInit.lmPst;
1036    cfmPst.selector = rgSchCb[inst].genCfg.bndCfmResp[suId].response.selector;
1037    cfmPst.prior = rgSchCb[inst].genCfg.bndCfmResp[suId].response.prior;
1038    cfmPst.route = rgSchCb[inst].genCfg.bndCfmResp[suId].response.route;
1039    cfmPst.region = rgSchCb[inst].genCfg.bndCfmResp[suId].response.mem.region;
1040    cfmPst.pool = rgSchCb[inst].genCfg.bndCfmResp[suId].response.mem.pool;
1041    
1042    memset(&cntrlCfm, 0, sizeof(RgMngmt));
1043
1044    switch(status)
1045    {
1046       case CM_BND_OK: /* status is OK */
1047          /* Change SAP state to Bound */
1048          rgSchCb[inst].tfuSap[suId].sapSta.sapState = LRG_BND;
1049          if (rgSchCb[inst].tfuSap[suId].sapCfg.bndTmr.enb == TRUE)
1050          {
1051             ret = rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[suId]);
1052          }
1053          /* Send Control Confirm with status as OK to Layer Manager */
1054          cntrlCfm.cfm.status = LCM_PRIM_OK;
1055          cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1056         /* Sending Status Indication to Layer Manager */
1057          rgSCHLmmStaInd((U8)(rgSchCb[inst].tfuSap->sapCfg.sapPst.srcInst - SCH_INST_START),
1058                LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_OK,
1059                LCM_CAUSE_LYR_SPECIFIC, (RgUstaDgn *)NULLP);
1060          break;
1061
1062       default:
1063          /* Change SAP state to UnBound */
1064          rgSchCb[inst].tfuSap[suId].sapSta.sapState = LRG_UNBND;
1065          if (rgSchCb[inst].tfuSap[suId].sapCfg.bndTmr.enb == TRUE)
1066          {
1067             ret = rgSCHLmmStopTmr(inst, RGSCH_BNDREQ_TMR, (PTR)&rgSchCb[inst].tfuSap[suId]);
1068          }
1069          /* Send Control Confirm with status as NOK to Layer Manager */
1070          cntrlCfm.cfm.status = LCM_PRIM_NOK;
1071          cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1072          break;
1073    }
1074    rgSchCb[inst].tfuSap[suId].numBndRetries = 0;
1075    cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1076    cntrlCfm.hdr.transId = rgSchCb[inst].genCfg.bndCfmResp[suId].transId;
1077
1078    ret = RgMiLrgSchCntrlCfm(&cfmPst, &cntrlCfm);
1079
1080    return (ret);
1081 }
1082
1083 /**
1084  * @brief Layer Manager Unsolicited Status Indication generation. 
1085  *
1086  * @details
1087  *
1088  *     Function : rgSCHLmmStaInd 
1089  *     
1090  *     This API is used by the other modules of MAC to send a unsolicited
1091  *     status indication to the Layer Manager.
1092  *     
1093  *  @param[in]  U16 category, the Alarm category
1094  *  @param[in]  U16 event, the Alarm event
1095  *  @param[in]  U16 cause, the cause of the Alarm
1096  *  @param[in]  RgUstaDgn *dgn, Alarm Diagonostics
1097  *  @return  S16
1098  *      -# ROK
1099  **/
1100 #ifdef ANSI
1101 S16 rgSCHLmmStaInd
1102 (
1103 Inst inst,
1104 U16  category,
1105 U16  event,
1106 U16  cause,
1107 RgUstaDgn *dgn
1108 )
1109 #else
1110 S16 rgSCHLmmStaInd(inst, category, event, cause, dgn) 
1111 Inst inst;
1112 U16 category;
1113 U16 event;
1114 U16 cause;
1115 RgUstaDgn *dgn;
1116 #endif
1117 {
1118    RgMngmt    usta;
1119
1120    if(rgSchCb[inst].rgSchInit.usta == FALSE)
1121    {
1122       return ROK;
1123    }
1124
1125    memset(&usta, 0, sizeof(RgMngmt));
1126
1127    SGetDateTime(&usta.t.usta.cmAlarm.dt);
1128    usta.t.usta.cmAlarm.category = category;
1129    usta.t.usta.cmAlarm.event = event;
1130    usta.t.usta.cmAlarm.cause = cause;
1131    if (dgn != NULLP)
1132    {
1133       memcpy(&usta.t.usta.dgn, dgn, sizeof(RgUstaDgn));
1134    }
1135
1136    rgSchCb[inst].rgSchInit.lmPst.selector = 
1137                        rgSchCb[inst].genCfg.ustaResp.response.selector;
1138    rgSchCb[inst].rgSchInit.lmPst.prior = 
1139                        rgSchCb[inst].genCfg.ustaResp.response.prior;
1140    rgSchCb[inst].rgSchInit.lmPst.route = 
1141                        rgSchCb[inst].genCfg.ustaResp.response.route;
1142    rgSchCb[inst].rgSchInit.lmPst.region = 
1143                        rgSchCb[inst].genCfg.ustaResp.response.mem.region;
1144    rgSchCb[inst].rgSchInit.lmPst.pool = 
1145                        rgSchCb[inst].genCfg.ustaResp.response.mem.pool;
1146    usta.hdr.transId = rgSchCb[inst].genCfg.ustaResp.transId;
1147
1148    return (RgMiLrgSchStaInd(&rgSchCb[inst].rgSchInit.lmPst, &usta));
1149 }
1150
1151 \f
1152 /**
1153  * @brief Scheduler instance timer call back function registered with SSI. 
1154  *
1155  * @details
1156  *
1157  *     Function :  schActvTmr
1158  *     
1159  *     This function is invoked by SSI for every timer activation
1160  *     period expiry. Note that SS_MT_TMR flag needs to be enabled for this
1161  *     as isntId is needed.As part of SRegTmr call for scheduler instance 
1162  *     SS_MT_TMR flag needs to be enabled and schActvTmr needs to be given as 
1163  *     callback function
1164  *     
1165  *  @return  S16
1166  *      -# ROK
1167  **/
1168 #ifdef ANSI
1169 S16 schActvTmr
1170 (
1171 Ent ent,
1172 Inst inst
1173 )
1174 #else
1175 S16 schActvTmr(ent, inst)
1176 Ent ent;
1177 Inst inst;
1178 #endif
1179 {
1180    Inst schInst = (inst  - SCH_INST_START);
1181
1182    /* Check if any timer in the scheduler instance has expired */ 
1183    cmPrcTmr(&rgSchCb[schInst].tmrTqCp,
1184             rgSchCb[schInst].tmrTq, (PFV) rgSCHLmmTmrExpiry);
1185  
1186    return ROK;
1187  
1188 } /* end of schActvTmr */
1189
1190 \f
1191 /**********************************************************************
1192  
1193          End of file
1194 **********************************************************************/