Merge "Get alarm-list implementation.[Issue-Id: ODUHIGH-230]"
[o-du/l2.git] / src / 5gnrmac / rg_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_lmm.c 
28   
29 **********************************************************************/
30
31 /** @file rg_lmm.c
32 @brief This file contains the Layer Management interface module implementation.
33        The functions for the configuration, control, status and statistics 
34        request primitives are defined here.
35 */
36 static const char* RLOG_MODULE_NAME="MAC";
37 static int RLOG_FILE_ID=220;
38 static int RLOG_MODULE_ID=4096;
39
40 /* header include files (.h) */
41 #include "common_def.h"
42 #include "rg_env.h"        /* MAC Environment Defines */
43 #include "crg.h"           /* CRG Interface defines */
44 #include "rgu.h"           /* RGU Interface defines */
45 #include "tfu.h"           /* RGU Interface defines */
46 #include "rg_sch_inf.h"    /* RGR Interface defines */
47 #include "lrg.h"           /* LRG Interface defines */
48 #include "rgr.h"           /* LRG Interface defines */
49 #include "rg.h"            /* MAC defines */
50 #include "rg_err.h"        /* MAC error defines */
51
52 /* header/extern include files (.x) */
53 #include "crg.x"           /* CRG Interface includes */
54 #include "rgu.x"           /* RGU Interface includes */
55 #include "tfu.x"           /* RGU Interface includes */
56 #include "rg_sch_inf.x"    /* SCH Interface includes */
57 #include "rg_prg.x"    /* PRG Interface includes */
58 #include "lrg.x"           /* LRG Interface includes */
59 #include "rgr.x"           /* LRG Interface includes */
60 #include "du_app_mac_inf.h"
61 #include "rg.x"            /* MAC includes */
62 #ifdef SS_DIAG
63 #include "ss_diag.h"        /* Common log file */
64 #endif
65 #include "ss_rbuf.h"
66 #include "ss_rbuf.x"
67 #include "lwr_mac.h"         /* MAC CL defines */
68 #include "mac_sch_interface.h"
69 #include "lwr_mac_upr_inf.h"
70 #include "mac.h"
71 #include "lwr_mac_phy.h"
72 #include "lwr_mac_fsm.h"
73
74 #ifdef __cplusplus
75 extern "C" {
76 #endif /* __cplusplus */
77 Void rgGetSId ARGS((SystemId *s));
78 #ifdef __cplusplus
79 }
80 #endif /* __cplusplus */
81
82 /* Public variable declaration */
83 LwrMacCb   lwrMacCb;
84 MacCb  macCb;
85
86 /* forward references */
87 static uint16_t rgLMMGenCfg ARGS((
88    Inst           inst,
89    RgCfg          *cfg           
90 ));
91
92 static uint16_t rgLMMSapCfg ARGS((
93    Inst           inst,
94    RgCfg          *cfg,
95    Elmnt          sapType
96 ));
97
98 static Void rgLMMShutdown ARGS((
99    Inst           inst
100 ));
101
102 static Void rgLMMFillCfmPst ARGS((
103    Pst           *reqPst,
104    Pst           *cfmPst,
105    RgMngmt       *cfm
106 ));
107
108 static Void rgLMMGenCntrl ARGS((
109 RgMngmt       *cntrl,
110 RgMngmt       *cfm,
111 Pst           *cfmPst
112 ));
113
114 static Void rgLMMSapCntrl ARGS((
115 RgMngmt       *cntrl,
116 RgMngmt       *cfm,
117 Pst           *cfmPst
118 ));
119
120 \f
121 /**
122  * @brief Task Initiation callback function. 
123  *
124  * @details
125  *
126  *     Function : rgActvInit
127  *     
128  *     This function is supplied as one of parameters during MAC's 
129  *     task registration. SSI will invoke this function once, after
130  *     it creates and attaches this TAPA Task to a system task.
131  *     
132  *  @param[in]  Ent entity, the entity ID of this task.     
133  *  @param[in]  Inst inst, the instance ID of this task.
134  *  @param[in]  Region region, the region ID registered for memory 
135  *              usage of this task.
136  *  @param[in]  Reason reason.
137  *  @return  S16
138  *      -# ROK
139  **/
140 S16 rgActvInit
141 (
142 Ent entity,            /* entity */
143 Inst inst,             /* instance */
144 Region region,         /* region */
145 Reason reason          /* reason */
146 )
147 {
148    Inst macInst ;
149
150    RG_IS_INST_VALID(inst);
151
152    macInst = inst - RG_INST_START;
153    /* Initialize the MAC TskInit structure to zero */
154    memset (&rgCb[macInst], 0, sizeof(RgCb));
155
156    /* Initialize the MAC TskInit with received values */
157    rgCb[macInst].rgInit.ent = entity;
158    rgCb[macInst].rgInit.inst = inst;
159    rgCb[macInst].rgInit.region = region;
160    rgCb[macInst].rgInit.pool = 0;
161    rgCb[macInst].rgInit.reason = reason;
162    rgCb[macInst].rgInit.cfgDone = FALSE;
163    rgCb[macInst].rgInit.acnt = FALSE;
164    rgCb[macInst].rgInit.usta = FALSE;
165    rgCb[macInst].rgInit.trc = FALSE;
166    rgCb[macInst].trcLen = 0; 
167 #ifdef DEBUGP
168 #ifdef RG_DEBUG
169    /* disabling debugs by default */
170    rgCb[macInst].rgInit.dbgMask = 0xffffffff; 
171 #endif
172 #endif /* DEBUGP */
173 #ifdef SS_DIAG
174    rgCb[macInst].rgInit.logMask = 0x0;
175 #endif
176    rgCb[macInst].rgInit.procId = SFndProcId();
177    rgCb[macInst].tfuSap.numBndRetries = 0;
178
179    /* Initialize Sap state */
180    rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
181    rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
182    rgCb[macInst].rguSap = NULLP;
183    rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
184
185    rgCb[macInst].inactiveCell = NULLP;
186    rgCb[macInst].cell         = NULLP;
187 #ifdef SS_RBUF
188    SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
189    SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
190 #endif
191
192    /* Initializing CL control block */
193    memset(&lwrMacCb, 0, sizeof(LwrMacCb));
194    lwrMacCb.region = region;
195    lwrMacCb.pool = 0;
196    lwrMacCb.clCfgDone = TRUE;
197    lwrMacCb.numCell = 0;
198    lwrMacCb.phyState = PHY_STATE_IDLE; 
199
200    /* Initialize Scheduler as well */
201    schActvInit(ENTMAC, (DEFAULT_CELLS + SCH_INST_START), DFLT_REGION, PWR_UP);
202
203    /* Initialize lower mac */
204    lwrMacLayerInit();
205
206    return ROK;
207
208 } /* rgActvInit */
209 \f
210 /**
211  * @brief Layer Manager Configuration request handler. 
212  *
213  * @details
214  *
215  *     Function : RgMiLrgCfgReq
216  *     
217  *     This function handles the configuration
218  *     request received from the Layer Manager.
219  *     -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
220  *        functions rgHdlGenCfg() or rgHdlSapCfg().
221  *     -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
222  *     
223  *  @param[in]  Pst *pst, the post structure     
224  *  @param[in]  RgMngmt *cfg, the configuration parameter's structure
225  *  @return  S16
226  *      -# ROK
227  **/
228 S16 RgMiLrgCfgReq
229 (
230 Pst      *pst,    /* post structure  */
231 RgMngmt  *cfg     /* config structure  */
232 )
233 {
234    uint16_t  ret = LCM_PRIM_OK;
235    uint16_t  reason = LCM_REASON_NOT_APPL;
236    RgMngmt   cfm;
237    Pst       cfmPst;
238    Inst      inst;
239
240
241
242    RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,\
243    "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n", pst->srcEnt, pst->srcInst,0,0);
244
245    RG_IS_INST_VALID(pst->dstInst);
246    inst = pst->dstInst - RG_INST_START;
247
248    /* Fill the post structure for sending the confirmation */
249    rgLMMFillCfmPst(pst, &cfmPst, cfg);
250
251    memset(&cfm, 0, sizeof(RgMngmt));
252
253 #ifdef LMINT3
254    cfm.hdr.transId = cfg->hdr.transId;
255 #endif
256
257
258    cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
259    switch(cfg->hdr.elmId.elmnt)
260    {
261       case STGEN:
262 #ifdef INTEL_WLS_MEM
263          /* Start WLS message receiver thread */
264          LwrMacStartWlsRcvr();
265          /* Allocate memory for UL transmissions */
266          LwrMacEnqueueWlsBlock();
267 #endif
268          reason = rgLMMGenCfg(inst,&cfg->t.cfg); 
269          break;
270       case STRGUSAP:
271       case STCRGSAP:
272       case STTFUSAP:
273          reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
274          break;
275       default:
276          ret = LCM_PRIM_NOK;
277          reason = LCM_REASON_INVALID_ELMNT;
278          RLOG1(L_ERROR, "Invalid Elmnt=%d",
279                cfg->hdr.elmId.elmnt);
280          break;
281    }
282
283    if (reason != LCM_REASON_NOT_APPL)
284    {
285       ret = LCM_PRIM_NOK;
286    }
287
288    cfm.cfm.status = ret;
289    cfm.cfm.reason = reason;
290
291    RgMiLrgCfgCfm(&cfmPst, &cfm);
292
293    return ROK;
294 }/*-- RgMiLrgCfgReq --*/
295
296 \f
297 /**
298  * @brief Layer Manager Statistics request handler. 
299  *
300  * @details
301  *
302  *     Function : RgMiLrgStsReq
303  *     
304  *     This function handles the statistics
305  *     request received from the Layer Manager.
306  *      -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
307  *      statistics from the rgCb global control block.
308  *      -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
309  *      -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
310  *     
311  *  @param[in]  Pst *pst, the post structure     
312  *  @param[in]  RgMngmt *sts, the statistics parameter's structure
313  *  @return  S16
314  *      -# ROK
315  **/
316 S16 RgMiLrgStsReq
317 (
318 Pst      *pst,    /* post structure  */
319 RgMngmt  *sts     /* statistics structure  */
320 )
321 {
322    Pst       cfmPst;
323    RgMngmt   cfm;
324    Inst      inst;
325
326    RG_IS_INST_VALID(pst->dstInst);
327    inst = pst->dstInst - RG_INST_START;
328    /* Fill the post structure for sending the confirmation */
329    rgLMMFillCfmPst(pst, &cfmPst, sts);
330
331    memset(&cfm, 0, sizeof(RgMngmt));
332
333 #ifdef LMINT3
334    cfm.hdr.transId = sts->hdr.transId;
335 #endif
336    SGetDateTime(&cfm.t.sts.dt);
337    cfm.cfm.status = LCM_PRIM_OK;
338    cfm.cfm.reason = LCM_REASON_NOT_APPL;
339    cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
340    cfm.t.sts.action = sts->t.sts.action;
341
342    /* Check if General Config Done */
343    if(rgCb[inst].rgInit.cfgDone != TRUE) 
344    {
345       cfm.cfm.status = LCM_PRIM_NOK;
346       cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
347       RgMiLrgStsCfm(&cfmPst,&cfm);
348       RLOG0(L_ERROR, "Gen Cfg not done");
349       return ROK;
350    }
351
352    switch(sts->hdr.elmId.elmnt)
353    {
354       case STGEN:
355          {
356             memcpy(&(cfm.t.sts.s.genSts), &rgCb[inst].genSts,
357                   sizeof(RgGenSts));
358             /* check if action is read and reset */
359             if(sts->t.sts.action == ARST)
360             {
361                rgCb[inst].genSts.numHarqFail = 0;
362             }
363             /* L2 statistics */
364 #ifdef MAC_SCH_STATS
365             {
366                RgGenSts *genSts = &(cfm.t.sts.s.genSts);
367                uint8_t       cqi = 0;
368                for(cqi=0; cqi <= 14; cqi++)
369                {
370                   /* Filling DL ACK/NACK stats */
371                   genSts->nackAckStats.dlCqiStat[cqi].mcs = \
372                      hqFailStats.dlCqiStat[cqi].mcs;
373                   genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
374                      hqFailStats.dlCqiStat[cqi].numOfNacks;
375                   genSts->nackAckStats.dlCqiStat[cqi].numOfAcks = 
376                      hqFailStats.dlCqiStat[cqi].numOfAcks;
377
378                   /* Filling UL ACK/NACK stats */
379                   genSts->nackAckStats.ulCqiStat[cqi].mcs = \
380                      hqFailStats.ulCqiStat[cqi].mcs;
381                   genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
382                      hqFailStats.ulCqiStat[cqi].numOfNacks;
383                   genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
384                      hqFailStats.ulCqiStat[cqi].numOfAcks;
385
386                   /* Filling DL HQ Retx stats */
387                   genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
388                      hqRetxStats.dlCqiStat[cqi].mcs;
389                   genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
390                      hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
391                   genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
392                      hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
393                   genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
394                      hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
395                   genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
396                      hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
397                   genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
398                      hqRetxStats.dlCqiStat[cqi].totalTx;
399
400                   /* Filling UL HQ Retx stats */
401                   genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
402                      hqRetxStats.ulCqiStat[cqi].mcs;
403                   genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
404                      hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
405                   genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
406                      hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
407                   genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
408                      hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
409                   genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
410                      hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
411                   genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
412                      hqRetxStats.ulCqiStat[cqi].totalTx;
413                }
414                /* Reset statistics */
415                if(sts->t.sts.action == ZEROSTS)
416                {
417                   memset(&hqRetxStats, 0, \
418                         sizeof(RgSchHqRetxStats));
419                   memset(&hqFailStats, 0, \
420                         sizeof(RgSchNackAckStats));
421                }
422             }
423 #endif /* MAC_SCH_STATS*/
424          }
425          break;
426       case STRGUSAP:
427          memcpy(&(cfm.t.sts.s.rguSts), &rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
428                   sizeof(RgSapSts));
429
430          /* check if action is read and reset */
431          if(sts->t.sts.action == ARST)
432             memset(&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
433
434          break;
435       case STCRGSAP:
436          memcpy(&(cfm.t.sts.s.crgSts), &rgCb[inst].crgSap.sapSts,
437                   sizeof(RgSapSts));
438
439          /* check if action is read and reset */
440          if(sts->t.sts.action == ARST)
441             memset(&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
442
443          break;
444       case STTFUSAP:
445          memcpy(&(cfm.t.sts.s.tfuSts), &rgCb[inst].tfuSap.sapSts,
446                   sizeof(RgSapSts));
447
448          /* check if action is read and reset */
449          if(sts->t.sts.action == ARST)
450             memset(&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
451
452          break;
453       default:
454          cfm.cfm.status = LCM_PRIM_NOK;
455          cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
456          RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
457          break;     
458    }
459    RgMiLrgStsCfm(&cfmPst,&cfm);
460    return ROK;
461 }/*-- RgMiLrgStsReq --*/
462
463 \f
464 /**
465  * @brief Layer Manager Status request handler. 
466  *
467  * @details
468  *
469  *     Function : RgMiLrgStaReq
470  *     
471  *     This function handles the solicited status
472  *     request received from the Layer Manager.
473  *      -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
474  *      particular SAP from the rgCb global control block.
475  *      -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
476  *     
477  *  @param[in]  Pst *pst, the post structure     
478  *  @param[in]  RgMngmt *sta, the status parameter's structure
479  *  @return  S16
480  *      -# ROK
481  **/
482 S16 RgMiLrgStaReq
483 (
484 Pst      *pst,    /* post structure  */
485 RgMngmt  *sta     /* status structure  */
486 )
487 {
488    Pst       cfmPst;
489    RgMngmt   cfm;
490    Inst      inst ;
491
492
493    RG_IS_INST_VALID(pst->dstInst);
494    inst = pst->dstInst - RG_INST_START;
495
496
497    /* Fill the post structure for sending the confirmation */
498    rgLMMFillCfmPst(pst, &cfmPst, sta);
499
500    if (sta->t.ssta.s.sysId.ptNmb != NULLP)
501    {
502       SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
503    }
504    
505    memset(&cfm, 0, sizeof(RgMngmt));
506    cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
507
508 #ifdef LMINT3
509    cfm.hdr.transId = sta->hdr.transId;
510 #endif
511    /* Check if General Config Done */
512    if(rgCb[inst].rgInit.cfgDone != TRUE) 
513    {
514       SGetDateTime(&cfm.t.ssta.dt);
515       if (SGetSBuf(cfmPst.region, cfmPst.pool, 
516                (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
517             != ROK)
518       {
519          RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
520          return ROK;
521       } 
522       memset((cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
523       rgGetSId(&cfm.t.ssta.s.sysId);
524       cfm.cfm.status = LCM_PRIM_NOK;
525       cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
526       cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
527       RgMiLrgStaCfm(&cfmPst, &cfm);
528       RLOG0(L_ERROR, "Gen Cfg not done");
529       return ROK;
530    }
531
532    switch(sta->hdr.elmId.elmnt)
533    {
534       case STGEN:
535          SGetDateTime(&cfm.t.ssta.dt);
536          if (SGetSBuf(cfmPst.region, cfmPst.pool, 
537              (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
538             != ROK)
539          {
540             RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
541             return ROK;
542          } 
543          memset((cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
544          rgGetSId(&cfm.t.ssta.s.sysId);
545          cfm.cfm.status = LCM_PRIM_OK;
546          cfm.cfm.reason = LCM_REASON_NOT_APPL;
547          RgMiLrgStaCfm(&cfmPst, &cfm);
548          break;
549       case STRGUSAP:
550          cfm.cfm.status = LCM_PRIM_OK;
551          cfm.cfm.reason = LCM_REASON_NOT_APPL;
552          SGetDateTime(&cfm.t.ssta.dt);
553          memcpy(&(cfm.t.ssta.s.rguSapSta), 
554                                 &rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
555             sizeof(RgSapSta));
556          RgMiLrgStaCfm(&cfmPst, &cfm);
557          break;
558       case STCRGSAP:
559          cfm.cfm.status = LCM_PRIM_OK;
560          cfm.cfm.reason = LCM_REASON_NOT_APPL;
561          SGetDateTime(&cfm.t.ssta.dt);
562          memcpy(&(cfm.t.ssta.s.crgSapSta), &rgCb[inst].crgSap.sapSta,
563          sizeof(RgSapSta));
564          RgMiLrgStaCfm(&cfmPst, &cfm);
565          break;
566       case STTFUSAP:
567          cfm.cfm.status = LCM_PRIM_OK;
568          cfm.cfm.reason = LCM_REASON_NOT_APPL;
569          SGetDateTime(&cfm.t.ssta.dt);
570          memcpy(&(cfm.t.ssta.s.tfuSapSta), &rgCb[inst].tfuSap.sapSta,
571          sizeof(RgSapSta));
572          RgMiLrgStaCfm(&cfmPst, &cfm);
573          break;
574       default:
575          cfm.cfm.status = LCM_PRIM_NOK;
576          cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
577          RgMiLrgStaCfm(&cfmPst, &cfm);
578          RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
579          break;     
580    }
581    return ROK;
582 }/*-- RgMiLrgStaReq --*/
583
584 \f
585 /**
586  * @brief Layer Manager Control request handler. 
587  *
588  * @details
589  *
590  *     Function : RgMiLrgCntrlReq
591  *     
592  *     This function handles the control
593  *     request received from the Layer Manager.
594  *      -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
595  *      and cntrl->t.cntrl.subAction, it performs the appropriate control action
596  *      of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
597  *      and layer shutdown.
598  *      -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
599  *     
600  *  @param[in]  Pst *pst, the post structure     
601  *  @param[in]  RgMngmt *cntrl, the control parameter's structure
602  *  @return  S16
603  *      -# ROK
604  **/
605 S16 RgMiLrgCntrlReq
606 (
607 Pst      *pst,    /* post structure  */
608 RgMngmt  *cntrl   /* control structure  */
609 )
610 {
611    S16       ret = ROK;            /* return value */
612    Pst       cfmPst;
613    RgMngmt   cfm;
614    Inst      inst;
615    /* Fill the post structure for sending the confirmation */
616
617    RG_IS_INST_VALID(pst->dstInst);
618    inst = pst->dstInst - RG_INST_START;
619
620    rgLMMFillCfmPst(pst, &cfmPst, cntrl);
621
622    memset(&cfm, 0, sizeof(RgMngmt));
623 #ifdef LMINT3
624    cfm.hdr.transId = cntrl->hdr.transId;
625 #endif
626    cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
627    cfm.t.cntrl.action = cntrl->t.cntrl.action;
628    cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
629
630    /* Check if General Config Done*/
631    if(rgCb[inst].rgInit.cfgDone != TRUE)
632    {
633       cfm.cfm.status = LCM_PRIM_NOK;
634       cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
635       cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
636       RgMiLrgCntrlCfm(&cfmPst, &cfm);
637       RLOG0(L_ERROR, "Gen Cfg not done");
638       return ROK;
639    }
640
641    /* General Config done, process the Control request */   
642    switch(cntrl->hdr.elmId.elmnt)
643    {
644       case STGEN:
645          rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
646          break;
647       case STTFUSAP:
648       case STRGUSAP:
649       case STCRGSAP:
650          rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
651          break;
652       default:
653          cfm.cfm.status = LCM_PRIM_NOK;
654          cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
655          RgMiLrgCntrlCfm(&cfmPst, &cfm);
656          RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
657          break;
658    }
659    return (ret);
660 }/*-- RgMiLrgCntrlReq --*/
661
662 \f
663 /**
664  * @brief SAP Configuration Handler. 
665  *
666  * @details
667  *
668  *     Function : rgLMMSapCfg
669  *     
670  *     This function in called by RgMiLrgCfgReq(). It handles the
671  *     interface SAP configuration of the LTE MAC layer. It 
672  *     initializes the sapState to LRG_UNBND. Returns
673  *     reason for success/failure of this function.
674  *     
675  *  @param[in]  Inst        inst
676  *  @param[in]  RgCfg *cfg, the Configuaration information 
677  *  @return  uint16_t
678  *      -# LCM_REASON_GENCFG_NOT_DONE
679  *      -# LCM_REASON_INVALID_SAP
680  *      -# LCM_REASON_NOT_APPL
681  **/
682 static uint16_t rgLMMSapCfg
683 (
684 Inst  inst,
685 RgCfg *cfg,            /* Configuaration information */
686 Elmnt sapType             /* Sap Type */
687 )
688 {
689    uint16_t          ret = LCM_REASON_NOT_APPL;
690    RgLowSapCfgInfo   *lowSapCfg = NULLP;
691    RgUpSapCfgInfo    *upSapCfg = NULLP;
692    RgUpSapCb         *upSapCb  = NULLP;
693
694
695       /* Check if Gen Config has been done */
696    if(rgCb[inst].rgInit.cfgDone != TRUE)
697          return (LCM_REASON_GENCFG_NOT_DONE);
698
699    switch(sapType)
700    {   
701       case STRGUSAP:
702          if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
703                (cfg->s.rguSap.selector != ODU_SELECTOR_TC) &&
704                (cfg->s.rguSap.selector != ODU_SELECTOR_LC))
705          {
706             ret = LCM_REASON_INVALID_PAR_VAL;
707             RLOG0(L_ERROR, "unsupported Selector value for RGU");
708             break;
709          }
710          upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
711          if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
712          { 
713             upSapCb->sapSta.sapState = LRG_UNBND;
714          }
715          upSapCfg = &(upSapCb->sapCfg);
716          upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
717          upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
718          upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
719          upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
720          upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
721          upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
722          upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
723          upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
724          upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
725          upSapCfg->sapPst.route = cfg->s.rguSap.route;
726          upSapCfg->sapPst.intfVer = 0; 
727          upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
728          upSapCfg->suId = cfg->s.rguSap.suId;
729          upSapCfg->spId = cfg->s.rguSap.spId;
730          /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
731           * there is cfg request with sap is 1*/
732          break;
733       case STCRGSAP:
734          if ((cfg->s.crgSap.selector != ODU_SELECTOR_TC) &&
735                (cfg->s.crgSap.selector != ODU_SELECTOR_LC))
736          {
737             ret = LCM_REASON_INVALID_PAR_VAL;
738             RLOG0(L_ERROR, "unsupported Selector value for CRG");
739             break;
740          }
741          if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
742          { 
743             rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
744          }
745          upSapCfg = &rgCb[inst].crgSap.sapCfg;
746
747          upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
748          upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
749          upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
750          upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
751          upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
752          upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
753          upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
754          upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
755          upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
756          upSapCfg->sapPst.route = cfg->s.crgSap.route;
757          upSapCfg->sapPst.intfVer = 0; 
758          upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
759          upSapCfg->suId = cfg->s.crgSap.suId;
760          upSapCfg->spId = cfg->s.crgSap.spId;
761          break;
762       case STTFUSAP:
763 #ifndef CL_MAC_LWLC 
764          if ((cfg->s.tfuSap.selector != ODU_SELECTOR_TC) &&
765                (cfg->s.tfuSap.selector != ODU_SELECTOR_LC))
766          {
767             ret = LCM_REASON_INVALID_PAR_VAL;
768             RLOG0(L_ERROR, "unsupported Selector value for TFU");
769             break;
770          }
771 #endif
772          if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) 
773          { 
774             rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
775          }
776          lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
777
778          lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
779          lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
780          lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
781          lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
782          lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
783          lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
784          lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
785          lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
786          lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
787          lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
788          lowSapCfg->sapPst.intfVer = 0; 
789          lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
790          lowSapCfg->suId = cfg->s.tfuSap.suId;
791          lowSapCfg->spId = cfg->s.tfuSap.spId;
792          memcpy(&lowSapCfg->bndTmr, &cfg->s.tfuSap.bndTmr,
793                    sizeof(TmrCfg));
794          break;
795       default:
796          /* would never reach here */
797          break;
798    }
799    return (ret);
800 }
801
802 \f
803 /**
804  * @brief General Configuration Handler. 
805  *
806  * @details
807  *
808  *     Function : rgLMMGenCfg
809  *     
810  *     This function in called by RgMiLrgCfgReq(). It handles the
811  *     general configuration of the LTE MAC layer. It initializes 
812  *     the hash lists of RgCb. Returns
813  *     reason for success/failure of this function.
814  *     
815  *  @param[in]  Inst        inst
816  *  @param[in]  RgCfg *cfg, the Configuaration information 
817  *  @return  uint16_t
818  *      -# LCM_REASON_NOT_APPL 
819  *      -# LCM_REASON_INVALID_MSGTYPE
820  *      -# LCM_REASON_MEM_NOAVAIL
821  **/
822 static uint16_t rgLMMGenCfg
823 (
824 Inst inst,
825 RgCfg *cfg            /* Configuaration information */
826 )
827 {
828    uint16_t    ret = LCM_REASON_NOT_APPL;
829
830
831    /* Check if General Configuration is done already */
832    if (rgCb[inst].rgInit.cfgDone == TRUE)
833    {
834       return (LCM_REASON_INVALID_MSGTYPE);
835    }
836    if ((cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_TC) &&
837          (cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_LC))
838    {
839       RLOG0(L_ERROR, "unsupported Selector value for RGU");
840       return (LCM_REASON_INVALID_PAR_VAL);
841    }
842    /* Update the Pst structure for LM interface */
843    memcpy(&rgCb[inst].rgInit.lmPst, &cfg->s.genCfg.lmPst,
844              sizeof(Pst));
845
846    rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
847    rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
848    rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
849    rgCb[inst].rgInit.lmPst.event = EVTNONE;
850
851    rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
852    rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
853    rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
854
855    macCb.macInst = rgCb[inst].rgInit.inst;
856    macCb.procId = rgCb[inst].rgInit.procId;
857
858    /* Initialize SAP States */
859    rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
860
861    if(cfg->s.genCfg.numRguSaps == 0)
862    {
863       RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
864       return RFAILED;
865    }
866
867    /* allocate RGR saps */
868    if (SGetSBuf(rgCb[inst].rgInit.region,
869             rgCb[inst].rgInit.pool,
870             (Data **)&rgCb[inst].rguSap,
871             (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
872    {
873       RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
874       return RFAILED;
875    }
876    rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
877
878    for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
879    {
880       rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
881       memset(&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
882    }
883    rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
884    /* Initialize the timer blocks */
885    cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
886    /* Initialzie the timer queue */   
887    memset(&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
888    /* Initialize the timer control point */
889    memset(&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
890    rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
891 #if 0
892    /* Timer Registration request to SSI */
893    if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
894             (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
895    {
896
897       RLOG0(L_ERROR, "Failed to register timer");
898
899       SPutSBuf(rgCb[inst].rgInit.region,
900             rgCb[inst].rgInit.pool,
901             (Data *)rgCb[inst].rguSap,
902             (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
903
904       return (LCM_REASON_MEM_NOAVAIL);
905    }
906 #endif
907    /* Set Config done in TskInit */
908    rgCb[inst].rgInit.cfgDone = TRUE;
909
910    return (ret);
911 }
912
913 \f
914 /***********************************************************
915  *
916  *     Func : rgLMMShutdown
917  *        
918  *
919  *     Desc : Handles the MAC layer shutdown request. Calls 
920  *     rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
921  *            
922  *
923  *     Ret  : Void
924  *
925  *     Notes: 
926  *
927  *     File : rg_lmm.c 
928  *
929  **********************************************************/
930 static Void rgLMMShutdown(Inst inst)
931 {
932    RgCellCb   *cell = rgCb[inst].cell;
933    uint8_t    idx;
934
935
936     /* Unbind the TFU Sap */
937    if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
938    {
939       //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
940       if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
941       {
942          rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap); 
943       } 
944       rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
945    }
946    if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
947    {
948       //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
949       rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
950    }
951
952
953    if(cell != NULLP)
954    {
955       for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
956       {
957          rgTOMRlsSf(inst,&cell->subFrms[idx]);
958       }
959
960       rgCFGFreeCellCb(cell);
961    }
962
963    /* Deleting the RGU SAPs */
964    SPutSBuf(rgCb[inst].rgInit.region,
965          rgCb[inst].rgInit.pool,
966          (Data *)rgCb[inst].rguSap,
967          (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
968    rgCb[inst].rguSap = NULLP;
969
970    rgCb[inst].inactiveCell = NULLP;
971    rgCb[inst].cell         = NULLP;
972
973    /* De-register the Timer Service */
974    (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
975          (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr); 
976
977    /* call back the task initialization function to intialize
978     * the global RgCb Struct */
979    rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region, 
980          rgCb[inst].rgInit.reason);
981
982    return;
983 }
984
985 \f
986 /***********************************************************
987  *
988  *     Func : rgLMMGenCntrl 
989  *        
990  *
991  *     Desc : Processes the LM control request for STGEN elmnt.
992  *            
993  *
994  *     Ret  : Void
995  *
996  *     Notes: 
997  *
998  *     File : rg_lmm.c 
999  *
1000  **********************************************************/
1001 static Void rgLMMGenCntrl 
1002 (
1003 RgMngmt       *cntrl,
1004 RgMngmt       *cfm,
1005 Pst           *cfmPst
1006 )
1007 {
1008    Inst      inst = (cfmPst->srcInst - RG_INST_START);
1009
1010    cfm->cfm.status = LCM_PRIM_OK;
1011    cfm->cfm.reason = LCM_REASON_NOT_APPL;
1012
1013
1014    switch(cntrl->t.cntrl.action)
1015    {
1016       case AENA:
1017          /* Action is Enable */
1018          switch(cntrl->t.cntrl.subAction)
1019          {
1020             case SATRC:
1021             /* Enable Traces */
1022                rgCb[inst].rgInit.trc = TRUE;
1023                rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1024                /*Store the response and TransId for sending the Traces */
1025                memcpy(&rgCb[inst].genCfg.trcResp.response, 
1026                &cntrl->hdr.response, sizeof(Resp));
1027                rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1028                
1029                break;
1030             case SAUSTA:   
1031             /* Enable Unsolicited Status (alarms) */
1032                rgCb[inst].rgInit.usta = TRUE;
1033                /*Store the response and TransId for sending the Alarms */
1034                memcpy(&rgCb[inst].genCfg.ustaResp.response, 
1035                &cntrl->hdr.response, sizeof(Resp));
1036                rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1037                break;
1038             case SADBG:
1039             /* Enable Debug Printing */
1040 #ifdef DEBUGP
1041                rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1042 #endif
1043                break;
1044 #ifdef SS_DIAG
1045             case SALOG:
1046                rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1047                break;
1048 #endif
1049
1050             default:
1051                cfm->cfm.status = LCM_PRIM_NOK;
1052                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1053                RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1054                break;
1055          }
1056          break;
1057       case ADISIMM:
1058          /* Action is Diable immidiately */
1059          switch(cntrl->t.cntrl.subAction)
1060          {
1061             case SATRC:
1062                /* Disable Traces */
1063                rgCb[inst].rgInit.trc = FALSE;
1064                break;
1065             case SAUSTA:
1066                /* Disable Unsolicited Status (alarms) */
1067                rgCb[inst].rgInit.usta = FALSE;
1068                break;
1069             case SADBG:
1070                /* Disable Debug Printing */
1071 #ifdef DEBUGP
1072                rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1073 #endif
1074                break;
1075 #ifdef SS_DIAG
1076             case SALOG:
1077                rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1078                break;
1079 #endif
1080
1081             default:
1082                cfm->cfm.status = LCM_PRIM_NOK;
1083                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1084                RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1085                break;
1086          }
1087          break;
1088       case ASHUTDOWN:
1089          /* Free all the memory dynamically allocated by MAC */
1090          rgLMMShutdown(inst);
1091          break;
1092       default:
1093          cfm->cfm.status = LCM_PRIM_NOK;
1094          cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1095          RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1096          break;
1097    }
1098    RgMiLrgCntrlCfm(cfmPst, cfm);
1099    return;
1100 }
1101
1102 \f
1103 /***********************************************************
1104  *
1105  *     Func : rgLMMSapCntrl 
1106  *        
1107  *
1108  *     Desc : Processes the LM control request for STxxxSAP elmnt.
1109  *            
1110  *
1111  *     Ret  : Void
1112  *
1113  *     Notes: 
1114  *
1115  *     File : rg_lmm.c 
1116  *
1117  **********************************************************/
1118 static Void rgLMMSapCntrl 
1119 (
1120 RgMngmt       *cntrl,
1121 RgMngmt       *cfm,
1122 Pst           *cfmPst
1123 )
1124 {
1125    Inst      inst = cfmPst->srcInst - RG_INST_START;
1126
1127    /* Only TFU Sap can be controlled by LM */
1128    switch(cntrl->hdr.elmId.elmnt)
1129    {
1130       case STTFUSAP:
1131          switch(cntrl->t.cntrl.action)
1132          {
1133             case ABND:
1134             /* Bind Enable Request */
1135                if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1136                    (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1137                {
1138                   cfm->cfm.status = LCM_PRIM_NOK;
1139                   cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1140                }
1141                else
1142                {
1143                   if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1144                   {
1145                      rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val, 
1146                      (PTR)&rgCb[inst].tfuSap);
1147                   }
1148                   /* Change SAP state */
1149                   rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1150                   rgCb[inst].tfuSap.numBndRetries++;
1151                   /* Store the response and TransId for sending 
1152                    * the Control confirm */
1153                   memcpy(&rgCb[inst].genCfg.bndCfmResp.response,
1154                            &cntrl->hdr.response, sizeof(Resp));
1155                   rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1156
1157                   /* Sending Status Indication to Layer Manager */
1158                   cfm->cfm.status = LCM_PRIM_OK_NDONE;
1159                   cfm->cfm.reason = LCM_REASON_NOT_APPL;
1160                   RgMiLrgCntrlCfm(cfmPst, cfm);
1161
1162                   //rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1163                                       //rgCb[inst].tfuSap.sapCfg.spId);
1164                   RETVOID;
1165                }
1166                break;
1167             case AUBND:
1168             /* Unbind request */
1169
1170                /* Check if the SAP is configured */
1171                if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1172                      (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1173                {
1174                   cfm->cfm.status = LCM_PRIM_NOK;
1175                   cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1176                }
1177                else
1178                {
1179                   //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1180                   if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1181                   {
1182                      rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1183                   }
1184                   /* Change SAP state */
1185                   rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1186                   cfm->cfm.status = LCM_PRIM_OK;
1187                   cfm->cfm.reason = LCM_REASON_NOT_APPL;
1188                }
1189                break;
1190             case ADEL:
1191                /* Delete SAP, does initialization of SAP */
1192                if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1193                    (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1194                {
1195                   //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1196                   if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1197                   {
1198                      rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1199                   }
1200                }
1201                memset(&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1202                rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1203                cfm->cfm.status = LCM_PRIM_OK;
1204                cfm->cfm.reason = LCM_REASON_NOT_APPL;
1205                break;
1206             default:
1207                cfm->cfm.status = LCM_PRIM_NOK;
1208                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1209                RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1210                cntrl->t.cntrl.action));
1211                break;
1212          }
1213          break;
1214       case STRGUSAP:
1215          switch(cntrl->t.cntrl.action)
1216          {
1217             case ADEL:
1218                memset(&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1219                rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1220                cfm->cfm.status = LCM_PRIM_OK;
1221                cfm->cfm.reason = LCM_REASON_NOT_APPL;
1222                break;
1223             default:
1224                cfm->cfm.status = LCM_PRIM_NOK;
1225                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1226                RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1227                cntrl->t.cntrl.action));
1228                break;
1229          }
1230          break;
1231       case STCRGSAP:
1232          switch(cntrl->t.cntrl.action)
1233          {
1234             case ADEL:
1235                memset(&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1236                rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1237                cfm->cfm.status = LCM_PRIM_OK;
1238                cfm->cfm.reason = LCM_REASON_NOT_APPL;
1239                break;
1240             default:
1241                cfm->cfm.status = LCM_PRIM_NOK;
1242                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1243                RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1244                
1245                break;
1246          }
1247          break;
1248       default:
1249          /* Would never here. */
1250          RETVOID;
1251    }
1252    RgMiLrgCntrlCfm(cfmPst, cfm);
1253    return;
1254 }
1255
1256 \f
1257 /***********************************************************
1258  *
1259  *     Func : rgLMMFillCfmPst 
1260  *        
1261  *
1262  *     Desc : Fills the Confirmation Post Structure cfmPst using the reqPst 
1263  *            and the cfm->hdr.response.
1264  *            
1265  *
1266  *     Ret  : Void
1267  *
1268  *     Notes: 
1269  *
1270  *     File : rg_lmm.c 
1271  *
1272  **********************************************************/
1273 static Void rgLMMFillCfmPst
1274 (
1275 Pst           *reqPst,
1276 Pst           *cfmPst,
1277 RgMngmt       *cfm
1278 )
1279 {
1280    Inst inst;
1281    inst = (reqPst->dstInst - RG_INST_START);
1282
1283    cfmPst->srcEnt    = rgCb[inst].rgInit.ent;
1284    cfmPst->srcInst   = rgCb[inst].rgInit.inst;
1285    cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1286    cfmPst->dstEnt    = reqPst->srcEnt;
1287    cfmPst->dstInst   = reqPst->srcInst;
1288    cfmPst->dstProcId = reqPst->srcProcId;
1289
1290    cfmPst->selector  = cfm->hdr.response.selector;
1291    cfmPst->prior     = cfm->hdr.response.prior;
1292    cfmPst->route     = cfm->hdr.response.route;
1293    cfmPst->region    = cfm->hdr.response.mem.region;
1294    cfmPst->pool      = cfm->hdr.response.mem.pool;
1295
1296    return;
1297 }
1298
1299 \f
1300 /**
1301  * @brief Timer start handler. 
1302  *
1303  * @details
1304  *
1305  *     Function : rgLMMStartTmr
1306  *     
1307  *     This function based on the input parameters starts the timer for 
1308  *     "tmrVal" duration. As of now MAC uses the timer functionality for 
1309  *     BndReq only. Hence there is no conditional code based on "tmrEvnt".
1310  *     
1311  *  @param[in]  Inst        inst
1312  *  @param[in]  S16   tmrEvnt, the Timer Event    
1313  *  @param[in]  uint32_t   tmrVal,  the Wait Time
1314  *  @param[in]  PTR   cb,  Entry for which Timer expired
1315  *  @return  S16
1316  *      -# ROK
1317  **/
1318 S16 rgLMMStartTmr
1319 (
1320 Inst               inst,
1321 S16                tmrEvnt,            /* Timer Event */
1322 uint32_t           tmrVal,             /* Wait Time */
1323 PTR                cb                  /* Entry for which Timer Expired */
1324 )
1325 {
1326    CmTmrArg    arg;
1327
1328
1329       UNUSED(tmrEvnt);
1330
1331    /* Initialize the arg structure */
1332    memset(&arg, 0, sizeof(CmTmrArg));
1333
1334    arg.tqCp = &rgCb[inst].tmrTqCp;
1335    arg.tq = rgCb[inst].tmrTq;
1336    arg.timers = rgCb[inst].tmrBlk;
1337    arg.cb = cb;
1338    arg.tNum = 0;
1339    arg.max = RG_MAX_TIMER;
1340    arg.evnt = RG_BNDREQ_TMR;
1341    arg.wait = tmrVal;      
1342    cmPlcCbTq(&arg);
1343
1344    return ROK;
1345 }
1346
1347 \f
1348 /**
1349  * @brief Timer stop handler. 
1350  *
1351  * @details
1352  *
1353  *     Function : rgLMMStopTmr
1354  *     
1355  *     This function based on the input parameters stops the timer for 
1356  *     "tmrEvnt". As of now MAC uses the timer functionality for 
1357  *     BndReq only. Hence there is no conditional code based on "tmrEvnt".
1358  *     Once the bind happens and this timer is stopped, the timer functionality
1359  *     is deregistered with SSI. As there is no further use of timer processing.
1360  *     
1361  *  @param[in]  Inst        inst
1362  *  @param[in]  S16   tmrEvnt, the Timer Event    
1363  *  @param[in]  PTR   cb,  Entry for which Timer expired
1364  *  @return  S16
1365  *      -# ROK
1366  *      -# RFAILED
1367  **/
1368 S16 rgLMMStopTmr
1369 (
1370 Inst               inst,             /* Scheduler instance */
1371 S16                tmrEvnt,            /* Timer Event */
1372 PTR                cb                  /* Entry for which Timer Expired */
1373 )
1374 {
1375    CmTmrArg   arg;
1376    uint8_t      i;
1377    S16        ret; 
1378
1379
1380    ret = RFAILED;
1381
1382    for(i=0;i<RG_MAX_TIMER;i++)
1383    {
1384       /* Search for the Timer Blocks */
1385       if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1386       {
1387          /* Initialize the arg structure */
1388          memset(&arg, 0, sizeof(CmTmrArg));
1389
1390          arg.tqCp = &rgCb[inst].tmrTqCp;
1391          arg.tq = rgCb[inst].tmrTq;
1392          arg.timers = rgCb[inst].tmrBlk;
1393          arg.cb = cb;
1394          arg.max = RG_MAX_TIMER;
1395          arg.evnt = NOTUSED;
1396          arg.wait = NOTUSED;
1397
1398          arg.tNum = i;   
1399          cmRmvCbTq(&arg);
1400          ret = ROK;
1401          break;
1402       }
1403
1404    }
1405
1406
1407    return (ret);
1408 }
1409
1410 \f
1411 /**
1412  * @brief Timer Expiry handler. 
1413  *
1414  * @details
1415  *
1416  *     Function : rgLMMTmrExpiry
1417  *     
1418  *     This is a callback function used as an input parameter to cmPrcTmr()
1419  *     to check expiry of any timer. In this function, the only concern is
1420  *     about tmrEvnt=Bind timer.
1421  *     
1422  *  @param[in]  PTR   cb,  Entry for which Timer expired
1423  *  @param[in]  S16   tmrEvnt, the Timer Event    
1424  *  @return  S16
1425  *      -# ROK
1426  **/
1427 S16 rgLMMTmrExpiry
1428 (
1429 PTR cb,               /* Pointer to timer control block */
1430 S16 tmrEvnt           /* Timer Event */
1431 )
1432 {
1433    S16        ret = ROK;
1434    RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1435    Inst          inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1436
1437    switch(tmrEvnt)
1438    {
1439       case RG_BNDREQ_TMR:
1440          tfuSap->numBndRetries++;
1441          if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1442          {
1443             rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1444                         LCM_CAUSE_TMR_EXPIRED, NULLP);
1445          }
1446          else
1447          {
1448             /* Restart the bind timer */
1449             if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1450             {
1451                ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1452                cb);
1453             }
1454
1455             /* Send bind request */
1456             //rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1457                                 //rgCb[inst].tfuSap.sapCfg.spId);
1458          }
1459          break;
1460       default:
1461          RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1462          ret = RFAILED;
1463          break;
1464    }
1465    return (ret);
1466 }
1467
1468
1469 \f
1470 /**
1471  * @brief Layer Manager Unsolicited Status Indication generation. 
1472  *
1473  * @details
1474  *
1475  *     Function : rgLMMStaInd 
1476  *     
1477  *     This API is used by the other modules of MAC to send a unsolicited
1478  *     status indication to the Layer Manager.
1479  *     
1480  *  @param[in]  Inst        inst
1481  *  @param[in]  uint16_t category, the Alarm category
1482  *  @param[in]  uint16_t event, the Alarm event
1483  *  @param[in]  uint16_t cause, the cause of the Alarm
1484  *  @param[in]  RgUstaDgn *dgn, Alarm Diagonostics
1485  *  @return  S16
1486  *      -# ROK
1487  **/
1488 S16 rgLMMStaInd
1489 (
1490 Inst inst,
1491 uint16_t category,
1492 uint16_t event,
1493 uint16_t cause,
1494 RgUstaDgn *dgn
1495 )
1496 {
1497    RgMngmt    usta;
1498    if(rgCb[inst].rgInit.usta == FALSE)
1499    {
1500       return ROK;
1501    }
1502
1503    memset(&usta, 0, sizeof(RgMngmt));
1504
1505    SGetDateTime(&usta.t.usta.cmAlarm.dt);
1506    usta.t.usta.cmAlarm.category = category;
1507    usta.t.usta.cmAlarm.event = event;
1508    usta.t.usta.cmAlarm.cause = cause;
1509    if (dgn != NULLP)
1510    {
1511       memcpy(&usta.t.usta.dgn, dgn, sizeof(RgUstaDgn));
1512    }
1513
1514    rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1515    rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1516    rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1517    rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1518    rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1519    usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1520
1521    return (RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1522 }
1523
1524 \f
1525 /**
1526  * @brief Layer Manager Trace Indication generation. 
1527  *
1528  * @details
1529  *
1530  *     Function : rgLMMTrcInd 
1531  *     
1532  *     This API is used by the other modules of MAC to send a 
1533  *     Trace indication to the Layer Manager.
1534  *     
1535  *  @param[in]  Inst        inst
1536  *  @param[in]   Buffer *srcMbuf, the Message Buffer .
1537  *  @param[in]   uint8_t event, the trace event.
1538  *  @return Void 
1539  **/
1540 Void rgLMMTrcInd
1541 (
1542 Inst   inst,
1543 Buffer *srcMbuf,    /* Message Buffer */
1544 uint8_t event            /* event */
1545 )
1546 {
1547    Buffer   *dstMbuf = NULLP;   
1548    MsgLen   bufLen  = 0;
1549    Data     *tempBuf;
1550    MsgLen   tempCnt;
1551    RgMngmt  trc;
1552    Pst      pst;
1553
1554
1555
1556    if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1557    {
1558       RLOG0(L_ERROR, "Trace Disabled.");
1559       return;
1560    }
1561    
1562    memset(&trc, 0, sizeof(RgMngmt));
1563
1564    pst = rgCb[inst].rgInit.lmPst;
1565    pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1566    pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1567    pst.route = rgCb[inst].genCfg.trcResp.response.route;
1568    pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1569    pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1570
1571    trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1572
1573    SGetDateTime(&trc.t.trc.dt);
1574
1575    /* Check if the whole buffer is to be sent in Trace indication */
1576    if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1577    {
1578       if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1579             != ROK)
1580       {
1581          RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1582          return;
1583       }
1584       trc.cfm.status = LCM_PRIM_OK;
1585       trc.cfm.reason = LCM_REASON_NOT_APPL;
1586       trc.t.trc.evnt = event;
1587
1588       /* Send Trace Indication to Layer manager */
1589       RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1590    }
1591    /* check if only a specified number of bytes are to be sent */
1592    else if(rgCb[inst].trcLen > 0)
1593    {
1594       /* Get the length of the recvd message buffer */
1595       if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1596       {
1597          RLOG0(L_ERROR, "SFndLenMsg Failed.");
1598          return;
1599       }
1600       /* Check if the recvd buffer size is less than request trace len */
1601       if(bufLen < rgCb[inst].trcLen)
1602       {
1603          /* Copy the whole of the recvd buffer in trace indication */
1604
1605          if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1606                != ROK)
1607          {
1608             RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1609             return;
1610          }
1611
1612          trc.cfm.status = LCM_PRIM_OK;
1613          trc.cfm.reason = LCM_REASON_NOT_APPL;
1614          trc.t.trc.evnt = event;
1615
1616          /* Send Trace Indication to Layer manager */
1617          RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1618       }
1619       /* if the recvd buffer size is greater than request trace len */
1620       if(bufLen >= rgCb[inst].trcLen)
1621       {
1622          /* Get a temporary buffer to store the msg */
1623          if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1624          {
1625             RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1626             return;
1627          }
1628
1629          /* Copy trcLen nos of bytes from the recvd message */
1630          if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)   
1631          {
1632             RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1633             return;
1634          }
1635
1636          if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1637          {
1638             RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1639             return;
1640          }
1641          /* Copy the tempBuf data to dst mBuf */
1642          if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1643          {
1644             RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1645             return;
1646          }
1647
1648          /*ccpu00117052 - MOD - Passing double pointer for proper NULLP 
1649            assignment */
1650          /* Free the memory allocated for tempBuf */
1651          rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1652
1653          trc.cfm.status = LCM_PRIM_OK;
1654          trc.cfm.reason = LCM_REASON_NOT_APPL;
1655          trc.t.trc.evnt = event;
1656
1657          /* Send Trace Indication to Layer manager */
1658          RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1659       }
1660    }
1661    return;
1662 }
1663
1664 \f
1665 /**
1666  * @brief Layer Manager Control Confirm generation handler
1667  *        for Bind Confirm reception at TFU interface.
1668  *        RgLiTfuBndCfm() forwards the confirmation to this 
1669  *        function. All SAP state related handling is restricted
1670  *        to LMM modules, hence the cfm forwarding.
1671  *
1672  * @details
1673  *
1674  *     Function : rgLMMBndCfm 
1675  *     
1676  *     This API is used by the LIM module of MAC to forward
1677  *     the Bind Confirm it receives over the TFU interface.
1678  *     
1679  *  @param[in]   Pst *pst, Post Structure
1680  *  @param[in]   SuId suId, Service user ID
1681  *  @param[in]   uint8_t status, Status
1682  *  @return  S16
1683  *      -# ROK
1684  **/
1685 S16 rgLMMBndCfm
1686 (
1687 Pst *pst,               /* Post Structure */
1688 SuId suId,              /* Service user ID */
1689 uint8_t status               /* Status */
1690 )
1691 {
1692    Inst      inst = pst->dstInst - RG_INST_START;
1693    S16       ret = ROK;
1694    RgMngmt   cntrlCfm;
1695    Pst       cfmPst;
1696
1697
1698    UNUSED(pst);
1699
1700    /* Check if the suId is valid */
1701    if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1702    {
1703       RLOG0(L_ERROR, "Invalid SuId");
1704       return RFAILED;
1705    }
1706
1707    /* check the Sap State */
1708    switch(rgCb[inst].tfuSap.sapSta.sapState)
1709    {
1710       case LRG_WAIT_BNDCFM:
1711          break;
1712       case LRG_BND:
1713          /* SAP is already bound */
1714          return ROK;
1715       default:
1716          return RFAILED;
1717    }
1718
1719    cfmPst = rgCb[inst].rgInit.lmPst;
1720    cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1721    cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1722    cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1723    cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1724    cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1725    
1726    memset(&cntrlCfm, 0, sizeof(RgMngmt));
1727
1728    switch(status)
1729    {
1730       case CM_BND_OK: /* status is OK */
1731          /* Change SAP state to Bound */
1732          rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1733          if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1734          {
1735             ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1736          }
1737          /* Send Control Confirm with status as OK to Layer Manager */
1738          cntrlCfm.cfm.status = LCM_PRIM_OK;
1739          cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1740          break;
1741
1742       default:
1743          /* Change SAP state to UnBound */
1744          rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1745          if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1746          {
1747             ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1748          }
1749          /* Send Control Confirm with status as NOK to Layer Manager */
1750          cntrlCfm.cfm.status = LCM_PRIM_NOK;
1751          cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1752          break;
1753    }
1754    rgCb[inst].tfuSap.numBndRetries = 0;
1755    cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1756    cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1757
1758    ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1759
1760    return (ret);
1761 }
1762
1763 \f
1764 /**
1765  * @brief LTE MAC timer call back function registered with SSI. 
1766  *
1767  * @details
1768  *
1769  *     Function :  rgActvTmr
1770  *     
1771  *     This function is invoked by SSI for every timer activation
1772  *     period expiry.
1773  *     
1774  *  @return  S16
1775  *      -# ROK
1776  **/
1777 S16 rgActvTmr(Ent ent,Inst inst)
1778 {
1779    Inst macInst = (inst  - RG_INST_START);
1780
1781    /* Check if any MAC timer has expired */ 
1782    cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1783
1784    return ROK;
1785
1786 } /* end of rgActvTmr */
1787
1788 /**********************************************************************
1789
1790   End of file
1791  **********************************************************************/