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