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