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