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