5ffe0506eb6d3cc2b2ad1578f76e20107a7384b7
[o-du/l2.git] / src / 5gnrrlc / kw_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**
20
21         Name:    LTE - RLC - Layer Manager file
22
23         Type:    C source file
24
25         Desc:    It contains the following common  functions for processing
26                  the all the external interfaces.
27                     -- RlcMiRlcConfigReq
28                     -- RlcMiRlcConfigCfm 
29                     -- RlcMiLkwCntrlReq
30                     -- RlcMiLkwCntrlCfm
31                     -- RlcMiLkwStaReq
32                     -- RlcMiLkwStaCfm
33                     -- RlcMiLkwStaInd
34                     -- RlcMiLkwStsReq
35                     -- RlcMiLkwStsCfm
36                     -- RlcMiLkwTrcInd 
37
38         File:     kw_lmm.c
39
40 *********************************************************************21*/
41 static const char* RLOG_MODULE_NAME="LMM";
42 static int RLOG_MODULE_ID=2048;
43 static int RLOG_FILE_ID=197;
44 /** @file kw_lmm.c
45 @brief RLC Layer Manager Module
46 **/
47
48 \f
49 /* header (.h) include files */
50 #include "common_def.h"
51 #include "lkw.h"           /* LKW defines */
52 #include "ckw.h"           /* CKW defines */
53 #include "kwu.h"           /* KWU defines */
54 #include "rgu.h"           /* RGU defines */
55 #include "kw_err.h"        /* Err defines */
56 #include "kw_env.h"        /* RLC environment options */
57
58 #include "kw.h"            /* RLC defines */
59 #include "kw_dl.h"
60 #include "kw_ul.h"
61 #include "kw_udx.h"
62
63 /* extern (.x) include files */
64 #include "lkw.x"           /* LKW */
65 #include "ckw.x"           /* CKW */
66 #include "kwu.x"           /* KWU */
67 #include "rgu.x"           /* RGU */
68
69 #include "kw.x"
70 #include "kw_udx.x"
71 #include "kw_dl.x"
72 #include "kw_ul.x"
73
74 #define RLC_MODULE RLC_DBGMASK_LMM
75
76 RLCStats gRlcStats;
77 \f
78 /*********************************************************************
79  *             Forward Declaration of LKW Porting Functions
80  ********************************************************************/
81 RlcCb *rlcCb[MAX_RLC_INSTANCES];
82 EXTERN S16 rlcActvTmr ARGS ((Ent ent, Inst inst));
83
84 PRIVATE Void rlcLmmSendCfm ARGS ((RlcCb *gCb,Pst *pst,RlcMngmt *cfm,U8 type,
85                                  Header *hdr));
86 PRIVATE S16 rlcLmmGenCfg ARGS ((RlcCb *gCb, RlcGenCfg *cfg));
87 PRIVATE S16 rlcLmmCfgKwuSap ARGS ((RlcCb *gCb,RlcSapCfg *cfg));
88 PRIVATE S16 rlcLmmCfgUdxSap ARGS ((RlcCb *gCb,RlcSapCfg *cfg));
89 PRIVATE S16 rlcLmmCfgCkwSap ARGS ((RlcCb *gCb,RlcSapCfg   *cfg));
90 PRIVATE S16 rlcLmmCfgRguSap ARGS ((RlcCb *gCb,RlcSapCfg   *cfg));
91 PRIVATE S16 rlcLmmGenCntrl ARGS ((RlcCb *gCb,RlcMngmt *cntrl));
92 PRIVATE S16 rlcLmmUdxSapCntrl ARGS ((RlcCb *gCb,RlcMngmt *cntrl));
93 PRIVATE S16 rlcLmmLSapCntrl ARGS ((RlcCb *gCb,RlcMngmt *cntrl));
94 PRIVATE S16 rlcLmmGetKwuSapSta ARGS ((RlcCb *gCb,RlcKwuSapSta *sta));
95 PRIVATE S16 rlcLmmGetRguSapSta ARGS ((RlcCb *gCb,RlcRguSapSta *sta));
96 PRIVATE S16 rlcLmmGetCkwCntSapSta ARGS ((RlcCb *gCb,RlcCkwCntSapSta *sta));
97 PRIVATE S16 rlcLmmGetGenSts ARGS ((RlcCb *gCb,RlcGenSts *sts,Action action));
98 PRIVATE S16 rlcLmmGetSapSts ARGS ((RlcCb *gCb,RlcMngmt *sts,Elmnt elmnt,Action 
99                                   action));
100
101 \f
102 /*********************************************************************
103  *             Primitives for RGU interface 
104  ********************************************************************/
105 /**
106  * @brief
107  *    Stores the general RLC configuration. 
108  * @details
109  *    It calculates the memory requirement of the Saps  
110  *    It also initializes the control blocks, the hash lists and registers
111  *    the timers. In case of error it rolls back and reports error in the 
112  *    confirm.If the general configuration is already done it is treated as 
113  *    reconfiguration, but right now reconfiguration is not supported.
114  * 
115  * @param[in]  gCb   RLC Instance Control Block
116  * @param[in]  cfm   RLC LM general config structure
117  * 
118  * @return  S16
119  *    LCM_REASON_NOT_APPL  (SUCCESS) 
120  *    LCM_REASON_MEM_NOAVAIL
121  *    LCM_REASON_REGTMR_FAIL
122  *    LCM_REASON_INVALID_PAR_VAL
123  *    LCM_REASON_HASHING_FAILED
124  */
125 #ifdef ANSI
126 PRIVATE S16 rlcLmmGenCfg
127 (
128 RlcCb       *gCb,
129 RlcGenCfg   *cfg
130 )
131 #else
132 PRIVATE S16 rlcLmmGenCfg(gCB,cfg)
133 RlcCb       *gCb;
134 RlcGenCfg   *cfg;
135 #endif
136 {
137    Size     rlcSapSize;
138    Size     rlcUdxSapSize;
139    S16      ret;
140    CmTqCp   *rlcTqCp;
141    Size     rguSapSize;
142
143    TRC2(rlcLmmGenCfg)
144
145    if(cfg->maxUe > RLC_MAX_UE) 
146    {
147 #if (ERRCLASS & ERRCLS_INT_PAR)
148       RLOG2(L_ERROR, "Invalid maxUe : Max [%lu] Received [%lu]", 
149             RLC_MAX_UE, 
150             cfg->maxUe);
151 #endif /* ERRCLASS & ERRCLS_INT_PAR */
152       return (LCM_REASON_INVALID_PAR_VAL);
153    }
154
155    if(cfg->maxKwuSaps > RLC_MAX_KWUSAPS)
156    {
157 #if (ERRCLASS & ERRCLS_INT_PAR)
158       RLOG2(L_ERROR, "Invalid maxKwuSaps : Max [%lu] Received [%lu]", 
159             RLC_MAX_KWUSAPS, 
160             cfg->maxKwuSaps);
161 #endif /* ERRCLASS & ERRCLS_INT_PAR */
162       return (LCM_REASON_INVALID_PAR_VAL);
163    }
164
165    if(cfg->maxUdxSaps > RLC_MAX_UDXSAPS)
166    {
167 #if (ERRCLASS & ERRCLS_INT_PAR)
168       RLOG2(L_ERROR, "Invalid maxUduSaps : Max [%lu] Received [%lu]", 
169             RLC_MAX_UDXSAPS, 
170             cfg->maxUdxSaps);
171 #endif /* ERRCLASS & ERRCLS_INT_PAR */
172       return (LCM_REASON_INVALID_PAR_VAL);
173    }
174    
175    if((cfg->maxRguSaps == 0) || (cfg->maxRguSaps > RLC_MAX_RGUSAPS))
176    {
177       
178
179       return (LCM_REASON_INVALID_PAR_VAL);
180    }
181    if(gCb->init.cfgDone == TRUE)
182    {
183       /* reconfiguration not supported */
184       return (LCM_REASON_RECONFIG_FAIL);
185    }
186
187    gCb->genCfg = *cfg;
188
189    /* Timer Queue Control point initialization */
190    rlcTqCp         = &(gCb->rlcTqCp);
191    rlcTqCp->tmrLen = RLC_TMR_LEN;
192    rlcTqCp->nxtEnt = 0;
193
194    if(gCb->genCfg.rlcMode == LKW_RLC_MODE_DL)
195    {
196       RLC_ALLOC(gCb,gCb->u.dlCb, sizeof (RlcDlCb));
197       if (gCb->u.dlCb == NULLP)
198       {  
199          RLOG0(L_FATAL,"Memory Allocation failed");   
200          return (LCM_REASON_MEM_NOAVAIL);
201       
202       }
203       /* allocate memory to the KWU sap's */
204       rlcSapSize = (Size)((Size) gCb->genCfg.maxKwuSaps *
205                    (Size)sizeof(RlcKwuSapCb));
206
207       RLC_ALLOC(gCb,gCb->u.dlCb->rlcKwuDlSap, rlcSapSize);
208
209 #if (ERRCLASS & ERRCLS_INT_PAR)
210       if(gCb->u.dlCb->rlcKwuDlSap == NULLP)
211       {
212          RLC_FREE(gCb,gCb->u.dlCb, sizeof (RlcDlCb));
213          RLOG0(L_FATAL,"Memory Allocation failed");   
214          return (LCM_REASON_MEM_NOAVAIL);
215       }
216 #endif /* ERRCLASS & ERRCLS_INT_PAR */
217
218       gCb->u.dlCb->numKwuSaps = gCb->genCfg.maxKwuSaps;
219
220       rlcUdxSapSize = (Size)((Size) gCb->genCfg.maxUdxSaps *
221                    (Size)sizeof(RlcUdxDlSapCb));
222
223       RLC_ALLOC(gCb,gCb->u.dlCb->udxDlSap, rlcUdxSapSize);
224 #if (ERRCLASS & ERRCLS_INT_PAR)
225       if(gCb->u.dlCb->udxDlSap == NULLP)
226       {
227          RLC_FREE(gCb,gCb->u.dlCb->rlcKwuDlSap, rlcSapSize);
228          RLC_FREE(gCb,gCb->u.dlCb, sizeof (RlcDlCb));
229          RLOG0(L_FATAL,"Memory Allocation failed");   
230          return (LCM_REASON_MEM_NOAVAIL);
231       }
232 #endif /* ERRCLASS & ERRCLS_INT_PAR */
233
234       rguSapSize = (Size)((Size) gCb->genCfg.maxRguSaps *
235                    (Size)sizeof(RlcRguSapCb));
236       RLC_ALLOC(gCb,gCb->u.dlCb->rguDlSap, rguSapSize);
237 #if (ERRCLASS & ERRCLS_INT_PAR)
238       if(gCb->u.dlCb->rguDlSap == NULLP)
239       {
240          RLC_FREE(gCb,gCb->u.dlCb->udxDlSap, rlcSapSize);
241          RLC_FREE(gCb,gCb->u.dlCb->rlcKwuDlSap, rlcSapSize);
242          RLC_FREE(gCb,gCb->u.dlCb, sizeof (RlcDlCb));
243       
244          RLCLOGERROR(gCb,ERRCLS_INT_PAR, EKW043, (ErrVal) cfg->maxUe,
245                    "rlcLmmGenCfg: SgetSBuf Failed for rguSap...!");
246          return (LCM_REASON_MEM_NOAVAIL);
247       }
248 #endif /* ERRCLASS & ERRCLS_INT_PAR */
249
250       
251       /* Initialize the Ue and Cell hash list */
252       ret = rlcDbmDlInit(gCb);
253       if (ret != ROK)
254       {
255          RLC_FREE(gCb,gCb->u.dlCb->udxDlSap, rlcSapSize);
256          RLC_FREE(gCb,gCb->u.dlCb->rlcKwuDlSap, rlcSapSize);
257          RLC_FREE(gCb,gCb->u.dlCb->rguDlSap, rguSapSize);
258          RLC_FREE(gCb,gCb->u.dlCb, sizeof (RlcDlCb));
259          RLOG0(L_FATAL,"RLC DL Initialization failed");   
260          return (LCM_REASON_MEM_NOAVAIL);
261       }
262 #if 0
263       /* Register the timer */
264 /*Pradeep: changing the SRegTmrMt() to SRegTmr()*/
265       if(SRegTmrMt(gCb->init.ent, gCb->init.inst, (U16)cfg->timeRes,
266               rlcActvTmr) != ROK)
267       {
268          RLC_FREE(gCb,gCb->u.dlCb->udxDlSap, rlcUdxSapSize);
269          RLC_FREE(gCb,gCb->u.dlCb->rlcKwuDlSap, rlcSapSize);
270          RLC_FREE(gCb,gCb->u.dlCb->rguDlSap, rguSapSize);
271          RLC_FREE(gCb,gCb->u.dlCb, sizeof (RlcDlCb));
272
273          return (LCM_REASON_REGTMR_FAIL);
274       }
275 #endif
276       /* initializations for background processing of freeing memory */
277       rlcUtlInitToBeFreed(gCb, &(gCb->u.dlCb->toBeFreed));
278       rlcUtlInitializeSelfPst(gCb);
279
280       if(SGetMsg(gCb->init.region, 
281                  gCb->init.pool,
282                  &(gCb->u.dlCb->selfPstMBuf)) != ROK)
283       {
284          RLC_FREE(gCb,gCb->u.dlCb->udxDlSap, rlcSapSize);
285          RLC_FREE(gCb,gCb->u.dlCb->rlcKwuDlSap, rlcSapSize);
286          RLC_FREE(gCb,gCb->u.dlCb->rguDlSap, rguSapSize);
287          RLC_FREE(gCb,gCb->u.dlCb, sizeof (RlcDlCb));
288
289          return (LCM_REASON_MEM_NOAVAIL);
290       
291       }
292 #ifdef LTE_L2_MEAS
293       rlcUtlL2MeasDlInit(gCb);
294 #endif
295    }
296    else if(gCb->genCfg.rlcMode == LKW_RLC_MODE_UL)
297    {
298       RLC_ALLOC(gCb,gCb->u.ulCb, sizeof (RlcUlCb));
299       if (gCb->u.ulCb == NULLP)
300       {     
301          RLOG0(L_FATAL,"Memory Allocation failed");   
302          return (LCM_REASON_MEM_NOAVAIL);
303       
304       }
305       /* allocate memory to the KWU sap's */
306       rlcSapSize = (Size)((Size) gCb->genCfg.maxKwuSaps *
307                    (Size)sizeof(RlcKwuSapCb));
308
309       RLC_ALLOC(gCb,gCb->u.ulCb->rlcKwuUlSap, rlcSapSize);
310
311 #if (ERRCLASS & ERRCLS_INT_PAR)
312       if(gCb->u.ulCb->rlcKwuUlSap == NULLP)
313       {
314          RLC_FREE(gCb,gCb->u.ulCb, sizeof (RlcUlCb));
315          RLOG0(L_FATAL,"Memory Allocation failed");   
316          return (LCM_REASON_MEM_NOAVAIL);
317       }
318 #endif /* ERRCLASS & ERRCLS_INT_PAR */
319
320       gCb->u.ulCb->numKwuSaps = gCb->genCfg.maxKwuSaps;
321
322       /* allocate memory to the KWU sap's */
323       rlcUdxSapSize = (Size)((Size) gCb->genCfg.maxUdxSaps *
324                    (Size)sizeof(RlcUdxUlSapCb));
325
326       RLC_ALLOC(gCb,gCb->u.ulCb->udxUlSap, rlcUdxSapSize);
327
328 #if (ERRCLASS & ERRCLS_INT_PAR)
329       if(gCb->u.ulCb->rlcKwuUlSap == NULLP)
330       {
331          RLC_FREE(gCb,gCb->u.ulCb->rlcKwuUlSap, rlcSapSize);
332          RLC_FREE(gCb,gCb->u.ulCb, sizeof (RlcUlCb));
333          RLOG0(L_FATAL,"Memory Allocation failed");   
334          return (LCM_REASON_MEM_NOAVAIL);
335       }
336 #endif /* ERRCLASS & ERRCLS_INT_PAR */
337
338       rguSapSize = (Size)((Size) gCb->genCfg.maxRguSaps *
339                    (Size)sizeof(RlcRguSapCb));
340       RLC_ALLOC(gCb,gCb->u.ulCb->rguUlSap, rguSapSize);
341 #if (ERRCLASS & ERRCLS_INT_PAR)
342       if(gCb->u.ulCb->rguUlSap == NULLP)
343       {
344          RLC_FREE(gCb,gCb->u.ulCb->rlcKwuUlSap, rlcSapSize);
345          RLC_FREE(gCb,gCb->u.ulCb->rguUlSap, rlcSapSize);
346          RLC_FREE(gCb,gCb->u.ulCb, sizeof (RlcUlCb));
347       
348          RLCLOGERROR(gCb,ERRCLS_INT_PAR, EKW043, (ErrVal) cfg->maxUe,
349                    "rlcLmmGenCfg: SgetSBuf Failed for rguSap...!");
350          return (LCM_REASON_MEM_NOAVAIL);
351       }
352 #endif /* ERRCLASS & ERRCLS_INT_PAR */
353
354       /* Initialize the Ue and Cell hash list */
355       ret = rlcDbmUlInit(gCb);
356       if (ret != ROK)
357       {
358          RLC_FREE(gCb,gCb->u.ulCb->udxUlSap, rlcUdxSapSize);
359          RLC_FREE(gCb,gCb->u.ulCb->rlcKwuUlSap, rlcSapSize);
360          RLC_FREE(gCb,gCb->u.ulCb->rguUlSap, rlcSapSize);
361          RLC_FREE(gCb,gCb->u.ulCb, sizeof (RlcUlCb));
362          RLOG0(L_FATAL,"RLC DL Initialization failed");   
363       }
364
365       /* Register the timer */
366 #if 0
367       if(SRegTmrMt(gCb->init.ent, gCb->init.inst, (U16)cfg->timeRes,
368               rlcActvTmr) != ROK)
369       {
370          RLC_FREE(gCb,gCb->u.ulCb->udxUlSap, rlcUdxSapSize);
371          RLC_FREE(gCb,gCb->u.ulCb->rlcKwuUlSap, rlcSapSize);
372          RLC_FREE(gCb,gCb->u.ulCb->rguUlSap, rlcSapSize);
373          RLC_FREE(gCb,gCb->u.ulCb, sizeof (RlcUlCb));
374
375          return (LCM_REASON_REGTMR_FAIL);
376       }
377 #endif
378 #ifdef LTE_L2_MEAS
379       rlcUtlL2MeasUlInit(gCb);
380 #endif
381    }
382    else
383    {
384 #if (ERRCLASS & ERRCLS_INT_PAR)
385       RLOG0(L_ERROR, "Received Invalid RLC Mode");
386 #endif /* ERRCLASS & ERRCLS_INT_PAR */
387
388       return (LCM_REASON_INVALID_PAR_VAL);
389    }
390    /* Timer Initialization  */
391    gCb->rlcTqCp.tmrLen = RLC_TMR_LEN;
392
393    cmMemset((U8*)gCb->rlcTq, NULLP, sizeof(CmTqType) * RLC_TMR_LEN);
394
395    RLC_MEM_CPY(&(gCb->init.lmPst), &cfg->lmPst, sizeof(Pst));
396
397    gCb->init.lmPst.srcProcId = gCb->init.procId;
398    gCb->init.lmPst.srcEnt = gCb->init.ent;
399    gCb->init.lmPst.srcInst = gCb->init.inst;
400    gCb->init.lmPst.event = EVTNONE;
401
402    /* kw002.201 For multi core and multi region,no need to reinitiailize the 
403     * region again . This would be done with kwActvInit from SSI */
404 #if !defined(SS_MULTICORE_SUPPORT) && !defined(SS_M_PROTO_REGION)
405    gCb->init.region = cfg->lmPst.region;
406 #endif /* !defined(SS_MULTICORE_SUPPORT) && !defined(SS_M_PROTO_REGION) */
407    gCb->init.pool   = cfg->lmPst.pool;
408
409    gCb->init.cfgDone = TRUE;
410
411    return (LCM_REASON_NOT_APPL);
412
413
414 /**
415  * @brief
416  *     Sends confirmation message to LM Called by RlcMiRlcConfigReq function
417  * 
418  * @param[in] gCb    RLC Instance Control Block
419  * @param[in] pst    Post structure
420  * @param[in] cfm    RLC LM structure 
421  * @param[in] type   Type of LM message
422  * @param[in] hdr    Message header
423  * 
424  * @return  S16
425  *     -# ROK
426  */
427 #ifdef ANSI
428 PRIVATE Void rlcLmmSendCfm
429 (
430 RlcCb      *gCb,
431 Pst       *pst,                
432 RlcMngmt   *cfm,               
433 U8        type,              
434 Header    *hdr              
435 )
436 #else
437 PRIVATE Void rlcLmmSendCfm(gCb,pst, cfm, type, hdr)
438 RlcCb      gCb;
439 Pst       *pst;            
440 RlcMngmt   *cfm;           
441 U8        type;          
442 Header    *hdr;         
443 #endif
444 {
445    Pst   rPst;   /* Reply post structure */
446
447    TRC2(rlcLmmSendCfm);
448
449    RLC_MEM_SET(&rPst, 0, sizeof(Pst));   
450  
451    /* reply post structure for confirmation */
452    if (gCb)
453    {
454       rPst.srcEnt = gCb->init.ent;
455       rPst.srcInst = gCb->init.inst;
456       cfm->hdr.entId.ent = gCb->init.ent;
457       cfm->hdr.entId.inst = gCb->init.inst;
458    }
459    else
460    {
461       rPst.srcEnt = pst->dstEnt;
462       rPst.srcInst = pst->dstInst;
463       cfm->hdr.entId.ent = pst->dstEnt;
464       cfm->hdr.entId.inst = pst->dstInst;
465    }
466    rPst.srcProcId = SFndProcId();
467    rPst.dstEnt = pst->srcEnt;
468    rPst.dstInst = pst->srcInst;
469    rPst.dstProcId = pst->srcProcId;
470    rPst.selector = hdr->response.selector;
471    rPst.prior = hdr->response.prior;
472    rPst.route = hdr->response.route;
473    rPst.region = hdr->response.mem.region;
474    rPst.pool= hdr->response.mem.pool;
475
476    /* Fill the reply header */
477    cfm->hdr.elmId.elmnt = hdr->elmId.elmnt;
478    cfm->hdr.transId = hdr->transId;
479
480    switch(type)
481    {
482       case TCFG:
483          RlcMiRlcConfigCfm(&rPst,cfm);
484          break;
485       case TCNTRL:
486          SGetDateTime(&(cfm->t.cntrl.dt));
487          RlcMiLkwCntrlCfm(&rPst,cfm);
488          break;
489       case TSTS:
490          SGetDateTime(&(cfm->t.sts.dt));
491          RlcMiLkwStsCfm(&rPst,0,cfm);
492          break;
493       case TSSTA:
494          SGetDateTime(&(cfm->t.ssta.dt));
495          RlcMiLkwStaCfm(&rPst,cfm);
496          break;
497       default:
498 #if (ERRCLASS & ERRCLS_INT_PAR)
499          RLOG0(L_ERROR, "Received Invalid Message Type");
500          if(!gCb)
501          {
502             fflush(stdout);
503          }
504 #endif /* ERRCLASS & ERRCLS_INT_PAR */
505          break;
506    }
507
508    RETVOID; 
509
510
511
512 /**
513  * @brief
514  *    This function processes configuration requests received from the layer 
515  *    manager.
516  *
517  * @details
518  *    The configuration requests can be for general configuration, or 
519  *    configuration of RGU, KWU, and CKW SAPs. The type of the configuration 
520  *    request can be determined from the elmId field in the header of the layer
521  *    manager message.This function is called by the layer manager to configure
522  *    RLC. 
523  *
524  *    This function implements the following logic: 
525  *
526  *    - if genCfg is not done, send negative Cfm to the layer manager; 
527  *
528  *    - switch (cfg->hdr.elmId.elmnt)
529  *       - case STGEN 
530  *          - update the genCfg field in RlCb; 
531  *          - allocate the maximum static memory required by the RLC product; 
532  *          - register the timer service by calling SReqTmr; 
533  *          - set CfgDone for not configuring again; 
534  *       - case STKWUSAP 
535  *          - if all the parameters are valid, then allocate the KwuSap control 
536  *            block; 
537  *          - update the SAP control block with the information provided in the 
538  *          - configuration request; 
539  *          - send configuration confirm with the status, success; 
540  *       - case STCKWSAP 
541  *          - if all the parametes are valid, then allocate the CkwSap control 
542  *            block; 
543  *          - update the SAP control block with the information provided in the
544  *            configuration request; 
545  *          - send configuration confirm with the status, success; 
546  *       - case STRGUSAP 
547  *          - if all the parametes are valid, then allocate the rguSap control 
548  *            block; 
549  *          - update the SAP control block with the information provided in the
550  *            configuration request; 
551  *          - send configuration confirm with the status, success; 
552  *       - case STUDXSAP 
553  *          - if all the parametes are valid, then allocate the udxSap control 
554  *            block; 
555  *          - update the SAP control block with the information provided in the
556  *            configuration request; 
557  *          - send configuration confirm with the status, success; 
558  *    - end switch;
559  *     
560  * @param[in] pst   post structure 
561  * @param[in] cfg   LM management structure 
562  * 
563  * @return S16
564  *    -# Success : ROK
565  *    -# Failure : RFAILED
566  */
567
568 #ifdef ANSI
569 S16 RlcMiRlcConfigReq 
570 (
571 Pst       *pst, 
572 RlcMngmt   *cfg
573 )
574 #else
575 S16 RlcMiRlcConfigReq (pst, cfg)
576 Pst       *pst;
577 RlcMngmt   *cfg;
578 #endif
579 {
580    Reason   reason;   /* failure reason */
581    RlcCb     *tRlcCb=NULLP;
582
583    TRC3(RlcMiRlcConfigReq);
584
585 #if (ERRCLASS & ERRCLS_INT_PAR)
586    /* Check if the instance is configured */
587    if (pst->dstInst >= MAX_RLC_INSTANCES)
588    {
589       cfg->cfm.status = LCM_PRIM_NOK;
590       cfg->cfm.reason = LCM_REASON_INVALID_INSTANCE;
591       rlcLmmSendCfm(tRlcCb,pst, cfg, TCFG, &cfg->hdr);     
592       return (RFAILED);
593    }
594 #endif
595    
596    tRlcCb =  RLC_GET_RLCCB(pst->dstInst);
597
598    if (!tRlcCb)
599    {
600       cfg->cfm.status = LCM_PRIM_NOK;
601       cfg->cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
602       rlcLmmSendCfm(tRlcCb,pst, cfg, TCFG, &cfg->hdr);     
603       return (RFAILED);
604    }
605    /* check configuration is done or not */
606    if ((tRlcCb->init.cfgDone != TRUE) && 
607        (cfg->hdr.elmId.elmnt != STGEN))
608    {
609       /*
610        * if general config is not over then use pst structure
611        * in primitive to communicate to stack manager
612        */
613
614       cfg->cfm.status = LCM_PRIM_NOK;
615       cfg->cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
616       rlcLmmSendCfm(tRlcCb,pst, cfg, TCFG, &cfg->hdr);     
617       return (RFAILED);
618    }
619
620    RLOG1(L_DEBUG, "RlcMiRlcConfigReq elmId(%d)", cfg->hdr.elmId.elmnt);
621
622    switch(cfg->hdr.elmId.elmnt)
623    {
624       case STGEN:
625       {
626          reason = rlcLmmGenCfg(tRlcCb,&cfg->t.cfg.s.gen);
627          break;
628       }
629       case STKWUSAP:
630       {
631          reason = rlcLmmCfgKwuSap(tRlcCb,&cfg->t.cfg.s.sap);
632          break;
633       }
634       case STCKWSAP:
635       {
636          reason = rlcLmmCfgCkwSap(tRlcCb,&cfg->t.cfg.s.sap);
637          break;
638       }
639       case STRGUSAP:
640       {
641          reason = rlcLmmCfgRguSap(tRlcCb,&cfg->t.cfg.s.sap);
642          break;
643       }
644       case STUDXSAP:
645       {
646          reason = rlcLmmCfgUdxSap(tRlcCb,&cfg->t.cfg.s.sap);
647          break;
648       }
649       default:
650       {
651          reason = LCM_REASON_INVALID_ELMNT;
652          break;
653       }   
654    }
655
656    if (reason == LCM_REASON_NOT_APPL)
657    {
658       cfg->cfm.status = LCM_PRIM_OK;
659       cfg->cfm.reason = LCM_REASON_NOT_APPL;
660       rlcLmmSendCfm(tRlcCb,pst, cfg, TCFG, &cfg->hdr);
661       return (ROK);
662    }
663    else
664    {
665       cfg->cfm.status = LCM_PRIM_NOK;
666       cfg->cfm.reason = reason;
667       rlcLmmSendCfm(tRlcCb,pst, cfg, TCFG, &cfg->hdr);
668       return (RFAILED);
669    }
670
671
672 /**
673  * @brief 
674  *    The layer manager initiates and uses the management-control procedure to 
675  *    control RLC elements.The RLC control request primitive (RlcMiLkwCntrlReq) 
676  *    can be called more than once and at any time after the 
677  *    management-configuration procedure.The control request primitive 
678  *    is confirmed by a RlcMiLkwCntrlCfm primitive.
679  *
680  * @details
681  *    This function implements the following logic: 
682  *  
683  *    - if(cfgDone = FALSE) 
684  *       - send negative confirmation to the layer manager; 
685  *       - return; 
686  *    - else 
687  *    - switch(cntrl->hdr.elmId.elmnt) 
688  *       -  case STGEN 
689  *           - switch (action) 
690  *           - case AENA 
691  *                - switch(subAction) 
692  *                - case SAUSTA 
693  *                     - enable the unsolicited status flag; 
694  *                     - send the control Cfm with success; 
695  *                - case SADBG 
696  *                     - set the debug mask; 
697  *                     - send the control Cfm with success; 
698  *                - case SATRC 
699  *                     - enable the trace flag; 
700  *                     - send the control Cfm with success; 
701  *            - case ADISIMM 
702  *               - switch(subAction) 
703  *               - case SAUSTA 
704  *                    - disable the unsolicited status flag; 
705  *                    - send the control Cfm with success; 
706  *               - case SATRC 
707  *                    - disable the trace flag; 
708  *                    - send the control Cfm with success; 
709  *          - case ASHUTDOWN 
710  *     - case STRGUSAP 
711  *          - Call LSapCntrl
712  *     - case STUDXSAP 
713  *          - Call UdxSapCntrl
714  *     - default  
715  *    - end else  
716  * 
717  * @param[in] pst     post structure
718  * @param[in] cntrl   LM management structure
719  * 
720  * @return S16
721  *    -# ROK
722  *    -# RFAILED
723  */
724 #ifdef ANSI
725 S16 RlcMiLkwCntrlReq
726 (
727 Pst       *pst, 
728 RlcMngmt   *cntrl
729 )
730 #else
731 S16 RlcMiLkwCntrlReq(pst, cntrl)
732 Pst       *pst;
733 RlcMngmt   *cntrl;
734 #endif
735 {
736    Reason   reason;   /* failure reason */
737    RlcCb     *tRlcCb=NULLP;
738
739    TRC3(RlcMiLkwCntrlReq)
740
741 #if (ERRCLASS & ERRCLS_INT_PAR)
742    /* Check if the instance is configured */
743    if (pst->dstInst >= MAX_RLC_INSTANCES)
744    {
745       cntrl->cfm.status = LCM_PRIM_NOK;
746       cntrl->cfm.reason =  LCM_REASON_INVALID_INSTANCE;
747
748       rlcLmmSendCfm(tRlcCb,pst, cntrl, TCNTRL, &cntrl->hdr);
749       return (RFAILED);
750    }
751 #endif
752    
753    tRlcCb =  RLC_GET_RLCCB(pst->dstInst);
754
755    if(!tRlcCb)
756    {
757       cntrl->cfm.status = LCM_PRIM_NOK;
758       cntrl->cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
759       rlcLmmSendCfm(tRlcCb,pst, cntrl, TCNTRL, &cntrl->hdr);
760       return (RFAILED);
761    }
762
763    if (!(tRlcCb->init.cfgDone))
764    {
765       cntrl->cfm.status = LCM_PRIM_NOK;
766       cntrl->cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
767       rlcLmmSendCfm(tRlcCb,pst, cntrl, TCNTRL, &cntrl->hdr);
768       return (RFAILED);
769    }
770    RLOG1(L_DEBUG, "RlcMiLkwCntrlReq(elmId(%d))", cntrl->hdr.elmId.elmnt);
771
772    /* In normal cases, LCM_REASON_NOT_APPL is returned in cfm.
773     * In all error cases appropriate reason is returned
774     * by the functions below
775     */
776
777    switch (cntrl->hdr.elmId.elmnt)
778    {
779       case STGEN:
780       {
781          /* general control */
782          reason = rlcLmmGenCntrl(tRlcCb,cntrl);
783          break;
784       }
785       case STRGUSAP:
786       {
787          /* Lower SAP control */
788          reason = rlcLmmLSapCntrl(tRlcCb,cntrl);
789          break;
790       }
791       case STUDXSAP:
792       {
793          /* Udx Sap cntrl */
794          reason = rlcLmmUdxSapCntrl(tRlcCb,cntrl);
795          break;
796       }
797       default:
798       {
799          reason = LCM_REASON_INVALID_ELMNT;
800          break;
801       }
802    } /* end switch */
803    
804    if (reason == LCM_REASON_NOT_APPL)
805    {
806       cntrl->cfm.status = LCM_PRIM_OK;
807       cntrl->cfm.reason = LCM_REASON_NOT_APPL;
808    }
809    else
810    {
811       cntrl->cfm.status = LCM_PRIM_NOK;
812       cntrl->cfm.reason = reason;
813    }
814
815    rlcLmmSendCfm(tRlcCb,pst, cntrl, TCNTRL, &cntrl->hdr);
816
817    return ROK;
818
819
820 /**
821  * @brief 
822  *    This function processes solicited status requests received from the layer
823  *    manager. The layer manager can request status information regarding the
824  *    system ID, RGUSAP,KWUSAP, or CKWSAP.
825  *
826  * @param[in] pst   post structure
827  * @param[in] sta   LM management structure
828  * @return S16
829  *    -# ROK (SUCCESS)
830  *    -# RFAILED
831  */
832 #ifdef ANSI
833 S16 RlcMiLkwStaReq
834 (
835 Pst       *pst, 
836 RlcMngmt   *sta
837 )
838 #else
839 S16 RlcMiLkwStaReq(pst, sta)
840 Pst       *pst;
841 RlcMngmt   *sta;
842 #endif
843 {
844    RlcMngmt   rSta;     /* Status */
845    Reason    reason;   /* Failure reason */
846    RlcCb      *tRlcCb=NULLP;
847
848    TRC3(RlcMiLkwStaReq);
849
850 #if (ERRCLASS & ERRCLS_INT_PAR)
851    /* Check if the instance is configured */
852    if (pst->dstInst >= MAX_RLC_INSTANCES)
853    {
854       sta->cfm.status = LCM_PRIM_NOK;
855       sta->cfm.reason = LCM_REASON_INVALID_INSTANCE;
856
857       rlcLmmSendCfm(tRlcCb,pst, sta, TSSTA, &sta->hdr);
858       return (RFAILED);
859    }
860 #endif
861    
862    tRlcCb =  RLC_GET_RLCCB(pst->dstInst);
863    if (!tRlcCb)
864    {
865       sta->cfm.status = LCM_PRIM_NOK;
866       sta->cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
867
868       rlcLmmSendCfm(tRlcCb,pst, sta, TSSTA, &sta->hdr);
869       return (RFAILED);
870    }
871
872    RLOG1(L_DEBUG, "Status request for elmId(%d))", sta->hdr.elmId.elmnt);
873
874    reason = LCM_REASON_NOT_APPL;
875
876    RLC_MEM_SET(&rSta, 0, sizeof(RlcMngmt));
877    switch (sta->hdr.elmId.elmnt)
878    {
879       case STSID:
880       {
881          reason = LCM_REASON_NOT_APPL;
882          rlcGetSId(&rSta.t.ssta.s.sysId);
883          break;
884       }
885       case STKWUSAP:
886       {
887          RLC_MEM_CPY (&rSta.t.ssta.s.rlckwuSap, 
888                      &sta->t.ssta.s.rlckwuSap, 
889                      sizeof (RlcKwuSapSta));
890
891          reason = rlcLmmGetKwuSapSta (tRlcCb,&rSta.t.ssta.s.rlckwuSap);
892          break;
893       }
894       case STRGUSAP:
895       {
896          RLC_MEM_CPY (&rSta.t.ssta.s.rguSap, 
897                      &sta->t.ssta.s.rguSap,
898                      sizeof (RlcRguSapSta));
899
900          reason = rlcLmmGetRguSapSta (tRlcCb,&rSta.t.ssta.s.rguSap);
901          break;
902       }
903       case STCKWSAP:
904       {
905          RLC_MEM_CPY (&rSta.t.ssta.s.ckwSap, 
906                      &sta->t.ssta.s.ckwSap,
907                      sizeof (RlcCkwCntSapSta));
908
909          reason = rlcLmmGetCkwCntSapSta (tRlcCb,&rSta.t.ssta.s.ckwSap);
910          break;
911       }
912       default:
913       {
914          reason = LCM_REASON_INVALID_ELMNT;
915          break;
916       }
917    } /* end of switch */
918
919    if (reason == LCM_REASON_NOT_APPL)
920    {
921       rSta.cfm.status = LCM_PRIM_OK;
922       rSta.cfm.reason = LCM_REASON_NOT_APPL;
923    }
924    else
925    {
926       rSta.cfm.status = LCM_PRIM_NOK;
927       rSta.cfm.reason = reason;
928    }
929    rlcLmmSendCfm(tRlcCb,pst, &rSta, TSSTA, &sta->hdr);
930
931    return ROK;
932
933
934 /**
935  * @brief 
936  *    This function processes statistics requests received from the layer
937  *    manager.
938  *
939  * @details  
940  *    After collecting the statistics, ir calls the statistics confirm function
941  *    to send the statistics to the layer manager.
942  *
943  *    - switch(sts->hdr.elmId.elmnt) 
944  *    - case STGEN 
945  *       - get the general statistics from the KW control block; 
946  *       - if (action = RESET) 
947  *          - reset the general statistic field in the RlCb; 
948  *          - call RlcMiLkwStsCfm to send statistics back to layer manager; 
949  *    - case STCKWSAP 
950  *    - case STKWUSAP 
951  *    - case STRGUSAP 
952  *        - get the SAP specific statistics from KW control block; 
953  *        - if (action = RESET) 
954  *       - reset the general statistic field in the RlCb; 
955  *       - call RlcMiLkwStsCfm to send statistics to the layer manager; 
956  *  -end switch;
957  *
958  * @param[in] pst      post structure
959  * @param[in] action   action 
960  * @param[in] sts      LM management structure
961  * 
962  * @return S16
963  *    -# ROK
964  *    -# RFAILED
965  */
966 #ifdef ANSI
967 S16 RlcMiLkwStsReq 
968 (
969 Pst      *pst, 
970 Action    action, 
971 RlcMngmt   *sts
972 )
973 #else
974 S16 RlcMiLkwStsReq (pst, action, sts)
975 Pst       *pst;
976 Action    action;
977 RlcMngmt   *sts;
978 #endif
979 {
980    RlcMngmt   rSts;     /* Statistics */
981    Reason    reason;   /* Reason for failure */
982    RlcCb     *tRlcCb=NULLP;
983
984    TRC3(RlcMiLkwStsReq);
985
986 #if (ERRCLASS & ERRCLS_INT_PAR)
987    /* Check if the instance is configured */
988    if (pst->dstInst >= MAX_RLC_INSTANCES)
989    {
990       rSts.cfm.status = LCM_PRIM_NOK;
991       rSts.cfm.reason = LCM_REASON_INVALID_INSTANCE;
992
993       rlcLmmSendCfm(tRlcCb,pst, &rSts, TCNTRL, &sts->hdr);
994       return (RFAILED);
995    }
996 #endif
997    
998    tRlcCb =  RLC_GET_RLCCB(pst->dstInst);
999    if (!tRlcCb)
1000    {
1001       rSts.cfm.status = LCM_PRIM_NOK;
1002       rSts.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
1003
1004       rlcLmmSendCfm(tRlcCb,pst, &rSts, TCNTRL, &sts->hdr);
1005       return (RFAILED);
1006    }
1007
1008    RLOG2(L_DEBUG, "RlcMiLkwStsReq(elmId(%d),action(%d))", 
1009                        action, 
1010                        sts->hdr.elmId.elmnt);
1011
1012    RLC_MEM_SET(&rSts, 0, sizeof(RlcMngmt));
1013
1014    switch (sts->hdr.elmId.elmnt)
1015    {
1016       case STGEN:
1017       {
1018          reason = rlcLmmGetGenSts(tRlcCb,&rSts.t.sts.s.gen, action);
1019          break;
1020       }
1021       case STKWUSAP:
1022       case STCKWSAP:
1023       {
1024          if( sts->hdr.elmId.elmnt == STKWUSAP)
1025          {
1026             /* kw005.201, modified the element of rlckwuSap from suId to spId */
1027             rSts.t.sts.s.rlckwuSap.spId = sts->t.sts.s.rlckwuSap.spId;
1028          }
1029          reason = rlcLmmGetSapSts(tRlcCb,&rSts, sts->hdr.elmId.elmnt, action);
1030          break;
1031       }
1032       default:
1033       {
1034          reason = LCM_REASON_INVALID_ELMNT;
1035          break;
1036       }
1037    } /* end switch */
1038
1039    if (reason == LCM_REASON_NOT_APPL)
1040    {
1041       rSts.cfm.status = LCM_PRIM_OK;
1042       rSts.cfm.reason = LCM_REASON_NOT_APPL;
1043    }
1044    else
1045    {
1046       rSts.cfm.status = LCM_PRIM_NOK;
1047       rSts.cfm.reason = reason;
1048    }
1049    rlcLmmSendCfm(tRlcCb,pst, &rSts, TSTS, &sts->hdr);
1050
1051    return ROK;
1052
1053
1054 /* kw005.201 added support for L2 Measurement */
1055 #ifdef LTE_L2_MEAS
1056 /**
1057 @brief 
1058 This function processes L2 Measurement requests received from the layer manager.
1059 The L2 Measurement is start for a time period and after the timer expiry, the 
1060 measurement confirm is sent.
1061
1062 -  Accept only one set of measurements.
1063 -  Allocate and initialise RlcL2MeasEvtCb.
1064 -  Validate if the measurement is already in progress.
1065    -  Loop through the existing measEvtCb with matching measType
1066       -  Check if measurement is running for any qci present in the measReq
1067       -  If present, move the qCi to list of invalid qCIs.
1068 -  Set RlcL2MeasEvtCb.measOn to TRUE for QCIs to be measured.
1069 -  For the number of measurements requested.
1070    -  For all Ues with RBs matching qCI.
1071       -  Add RbCb to the RB linked list.
1072       -  Set rlcRbCb.measOn to measurement type.
1073       -  If Meas type is DL_DELAY
1074          -  Update COUNT to startCount.
1075 -  Start l2Timer
1076
1077  *  @param[in] pst      post structure
1078  *  @param[in] action   action 
1079  *  @param[in] cfg      LM management structure
1080  *  @return S16
1081  *      -# Success : ROK
1082  *      -# Failure : RFAILED
1083 */
1084 #ifdef ANSI
1085 S16 RlcMiLkwL2MeasReq 
1086 (
1087 Pst            *pst, 
1088 RlcL2MeasReqEvt *measReqEvt 
1089 )
1090 #else
1091 S16 RlcMiLkwL2MeasReq (pst, measReqEvt)
1092 Pst            *pst; 
1093 RlcL2MeasReqEvt *measReqEvt;
1094 #endif
1095 {
1096    S16            ret = ROK;
1097    U16            cntr;
1098    U8             measType;
1099    RlcL2MeasCfmEvt measCfmEvt;
1100
1101    RlcCb     *tRlcCb;
1102
1103    TRC3(RlcMiLkwL2MeasReq);
1104
1105    tRlcCb =  RLC_GET_RLCCB(pst->dstInst);
1106
1107    /* Initialize measCfmEvt */
1108    RLC_MEM_ZERO(&measCfmEvt, sizeof(RlcL2MeasCfmEvt));
1109    /* validate the received measReqEvt */
1110    /*LTE_L2_MEAS_PHASE2*/
1111    if(measReqEvt->measPeriod != 0)
1112    {
1113       /* L2 MEAS AGHOSH */
1114       if((measReqEvt->measReq.measType & LKW_L2MEAS_DL_IP)|| 
1115             (measReqEvt->measReq.measType & LKW_L2MEAS_UL_IP))
1116       {
1117          ret = rlcUtlValidateIpThL2Meas(measReqEvt, &measCfmEvt);
1118       }
1119
1120       if(ret != ROK)
1121       {
1122 #if (ERRCLASS & ERRCLS_ADD_RES)
1123 #endif /* ERRCLASS & ERRCLS_ADD_RES */
1124          rlcUtlSndUlL2MeasNCfm(tRlcCb, measReqEvt, &measCfmEvt);
1125          RLC_FREE(tRlcCb, measReqEvt, sizeof(RlcL2MeasReqEvt))
1126          return RFAILED;
1127       }
1128    }
1129
1130    measType = measReqEvt->measReq.measType;
1131
1132    if((measType != LKW_L2MEAS_DL_IP) &&
1133       (measType !=  LKW_L2MEAS_ACT_UE) &&
1134       (measType !=  LKW_L2MEAS_DL_DISC) &&
1135       (measType != LKW_L2MEAS_DL_DELAY) && 
1136       (measType != LKW_L2MEAS_UU_LOSS) &&
1137       (measType !=  LKW_L2MEAS_UL_IP))/* || (qci > LKW_MAX_QCI)*/
1138    {
1139       measCfmEvt.transId = measReqEvt->transId;
1140       measCfmEvt.measType = measType;
1141       measCfmEvt.status.status = LCM_PRIM_NOK;
1142       measCfmEvt.status.reason = LKW_CAUSE_INVALID_MEASTYPE;
1143       rlcUtlSndDlL2MeasNCfm(tRlcCb, measReqEvt, &measCfmEvt);
1144       RLC_FREE(tRlcCb, measReqEvt, sizeof(RlcL2MeasReqEvt))
1145       return ROK;
1146    }
1147
1148    /* for UL IP throughput meas enable for all QCIs */
1149    if(measType & LKW_L2MEAS_UL_IP)
1150    {
1151       for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
1152       {
1153          tRlcCb->u.ulCb->rlcL2Cb.measOn[cntr] |= LKW_L2MEAS_UL_IP;
1154       }
1155    }
1156   
1157    if(measType & 
1158       (LKW_L2MEAS_DL_IP | LKW_L2MEAS_DL_DISC | 
1159       LKW_L2MEAS_DL_DELAY | LKW_L2MEAS_UU_LOSS))
1160    {
1161       RlcL2MeasReqEvt *measEvt;
1162       Pst      *udxPst;
1163
1164       udxPst = &(RLC_GET_UDX_SAP(tRlcCb)->pst);
1165       
1166       RLC_ALLOC_SHRABL_BUF(udxPst->region, 
1167                           udxPst->pool,
1168                           measEvt, 
1169                           sizeof(RlcL2MeasReqEvt));
1170
1171 #if (ERRCLASS & ERRCLS_ADD_RES) /* KW_FIX */ 
1172       if(measEvt == NULLP)
1173       {
1174          RLOG0(L_FATAL,"Memory Allocation failed");   
1175          return RFAILED;
1176       }   
1177 #endif      
1178       cmMemcpy((Void*)measEvt, (Void*)measReqEvt, sizeof(RlcL2MeasReqEvt));
1179       /*Redirect the request to DL task */
1180       /* NOTE:As of today, there are no cases where the Req will fail at DL
1181          as long as it reached the DL, so we don't wait for a confirmation from
1182          DL to send the confirmation to LM*/
1183       /* The interface for sending a confirmation back does not exist today;
1184          it needs to be created when the need arises */
1185       rlcUlUdxL2MeasReq(&(RLC_GET_UDX_SAP(tRlcCb)->pst),measEvt);
1186    }
1187
1188    /* We need to copy the transId for sending back confirms later */
1189    for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
1190    {
1191       RlcL2MeasEvtCb* measEvtCb = &(tRlcCb->u.ulCb->rlcL2Cb.rlcL2EvtCb[cntr]);
1192       if(measEvtCb->measCb.measType & measType)
1193       {
1194          measEvtCb->transId= measReqEvt->transId;
1195       }
1196    }
1197    /*RLC_FREE(tRlcCb, measReqEvt, sizeof(RlcL2MeasReqEvt));*/
1198
1199    return (ret);
1200 } /* RlcMiLkwL2MeasReq */
1201
1202 /**
1203 @brief 
1204 This function processes L2 Measurement stop request received from the layer manager.
1205 After receving this request, RLC stops L2 Measurement
1206  *  @param[in] pst      post structure
1207  *  @param[in] measType meas Type 
1208  *  @return S16
1209  *      -# Success : ROK
1210  *      -# Failure : RFAILED
1211 */
1212
1213 #ifdef ANSI
1214 S16 RlcMiLkwL2MeasStopReq
1215 (
1216 Pst            *pst,
1217 U8             measType
1218 )
1219 #else
1220 S16 RlcMiLkwL2MeasStopReq (pst, measType)
1221 Pst            *pst;
1222 U8             measType;
1223 #endif
1224 {
1225    S16 ret = ROK;
1226    RlcL2MeasEvtCb *measEvtCb = NULLP;
1227
1228    U16            cntr;
1229    U8             status = ROK;
1230    RlcCb     *tRlcCb;
1231
1232    TRC3(RlcMiLkwL2MeasStopReq);
1233
1234    tRlcCb =  RLC_GET_RLCCB(pst->dstInst);
1235
1236    /* reset the counter values for the measurement that is stopped */
1237    for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
1238    {
1239       measEvtCb = &(tRlcCb->u.ulCb->rlcL2Cb.rlcL2EvtCb[cntr]);
1240       if(measEvtCb->measCb.measType & measType)
1241       {
1242          rlcUtlResetUlL2MeasInRlcRb(tRlcCb, &measEvtCb->measCb, measType);
1243
1244       }
1245    }   
1246
1247    /* for UL IP throughput meas disable for all QCIs */
1248    if(measType & LKW_L2MEAS_UL_IP)
1249    {
1250       for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
1251       {
1252          tRlcCb->u.ulCb->rlcL2Cb.measOn[cntr] &= ~LKW_L2MEAS_UL_IP;
1253       }
1254    }
1255    
1256    if((measType & LKW_L2MEAS_DL_IP) || (measType & LKW_L2MEAS_DL_DISC)
1257        || (measType & LKW_L2MEAS_DL_DELAY))
1258    {
1259       /*Redirect the request to DL task */
1260       rlcUlUdxL2MeasStopReq(&(RLC_GET_UDX_SAP(tRlcCb)->pst),measType);
1261       /*return ROK;*/
1262    }
1263    /*cmMemset((U8*)&measCfmEvt, 0, sizeof(RlcL2MeasCfmEvt)); */
1264
1265    status = LCM_PRIM_OK; 
1266    RlcMiLkwL2MeasStopCfm(&tRlcCb->genCfg.lmPst, measType,status); 
1267    
1268    return (ret);
1269 }
1270 /**
1271 @brief 
1272 This function processes L2 Measurement Send request received from the layer manager.
1273 After receving this request, RLC sends L2 Measurement
1274  *  @param[in] pst      post structure
1275  *  @param[in] measType meas Type 
1276  *  @return S16
1277  *      -# Success : ROK
1278  *      -# Failure : RFAILED
1279 */
1280
1281 #ifdef ANSI
1282 S16 RlcMiLkwL2MeasSendReq
1283 (
1284 Pst            *pst,
1285 U8             measType
1286 )
1287 #else
1288 S16 RlcMiLkwL2MeasSendReq (pst, measType)
1289 Pst            *pst;
1290 U8             measType;
1291 #endif
1292 {
1293    /*S16 ret = ROK;*/
1294    RlcL2MeasEvtCb *measEvtCb = NULLP;
1295    U16            cntr;
1296    RlcCb     *tRlcCb;
1297    TRC3(RlcMiLkwL2MeasSendReq);
1298
1299    tRlcCb =  RLC_GET_RLCCB(pst->dstInst);
1300    
1301    /* In case of addition of any new measType here ,appropriate handling 
1302     * has to be done in RLC DL (rlcUtlSndDlL2MeasCfm)*/
1303    if(measType & 
1304       (LKW_L2MEAS_DL_DISC | LKW_L2MEAS_DL_DELAY 
1305        | LKW_L2MEAS_UU_LOSS| LKW_L2MEAS_DL_IP))
1306    {
1307       /*Redirect the request to DL task */
1308       rlcUlUdxL2MeasSendReq(&(RLC_GET_UDX_SAP(tRlcCb)->pst),measType);
1309       /* L2 MEAS AGHOSH */
1310       /*return ROK;*/
1311    }
1312
1313    for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
1314    {
1315       measEvtCb = &(tRlcCb->u.ulCb->rlcL2Cb.rlcL2EvtCb[cntr]);
1316       /* L2 MEAS AGHOSH */
1317       if(measEvtCb->measCb.measType & measType)
1318       {
1319          rlcUtlHdlL2TmrExp(tRlcCb, measEvtCb);
1320       }
1321    }
1322
1323    return ROK;
1324 }
1325 #endif /* LTE_L2_MEAS */
1326
1327 /**
1328  * @brief
1329  *    This function configures the RLC data sap
1330  *
1331  * @param[in]  gCb   RLC Instance Control Block
1332  * @param[in]  cfg   RLC LM Sap configuration structure
1333  *
1334  * @return  S16
1335  *    -# LCM_REASON_NOT_APPL  (SUCCESS)
1336  *    -# LCM_REASON_INVALID_SAP 
1337  *    -# LCM_REASON_MEM_NOAVAIL 
1338  *    -# LCM_REASON_RECONFIG_FAIL 
1339  */
1340 #ifdef ANSI
1341 PRIVATE S16 rlcLmmCfgKwuSap
1342 (
1343 RlcCb       *gCb,
1344 RlcSapCfg   *cfg                
1345 )
1346 #else
1347 PRIVATE S16 rlcLmmCfgKwuSap(gCb,cfg)
1348 RlcCb       *gCb;
1349 RlcSapCfg   *cfg;               
1350 #endif
1351 {
1352    RlcKwuSapCb   *rlcKwuSapCb;
1353    TRC2(rlcLmmCfgKwuSap)
1354
1355 #if (ERRCLASS & ERRCLS_INT_PAR)
1356    /* Validate the protocol parameters */
1357    if((cfg->sapId >= (S16)gCb->genCfg.maxKwuSaps) || (cfg->sapId < 0))
1358    {
1359       return (LCM_REASON_INVALID_PAR_VAL);
1360    }
1361 #endif /* ERRCLASS & ERRCLS_INT_PAR */
1362
1363    rlcKwuSapCb = (gCb->genCfg.rlcMode == LKW_RLC_MODE_DL) ?
1364               (RlcKwuSapCb*)(gCb->u.dlCb->rlcKwuDlSap + cfg->sapId):
1365               (RlcKwuSapCb*)(gCb->u.ulCb->rlcKwuUlSap + cfg->sapId);
1366
1367 #if (ERRCLASS & ERRCLS_INT_PAR)
1368    /* Check for reconfiguration */
1369    if (rlcKwuSapCb->state != RLC_SAP_NOT_CFG)
1370    {
1371       RLOG2(L_ERROR,"RLC Mode [%d] : Invalid rlckwuSap State [%d]",
1372             gCb->genCfg.rlcMode, rlcKwuSapCb->state);
1373       /* reconfiguration not allowed */
1374       return (LCM_REASON_RECONFIG_FAIL);
1375    }
1376 #endif /* ERRCLASS & ERRCLS_INT_PAR */
1377
1378    /* Fill the parameters */
1379    RLC_FILL_SAP_HELPER(rlcKwuSapCb, cfg, gCb);
1380
1381    return (LCM_REASON_NOT_APPL);
1382
1383
1384 /**
1385  * @brief
1386  *    This function configures the RLC control sap
1387  *
1388  * @param[in]  gCb   RLC Instance Control Block
1389  * @param[in]  cfg   RLC LM Sap configuration structure
1390  * 
1391  * @return  S16
1392  *    -# LCM_REASON_NOT_APPL (SUCCESS)
1393  *    -# LCM_REASON_INVALID_SAP
1394  *    -# LCM_REASON_INVALID_SAP 
1395  *    -# LCM_REASON_RECONFIG_FAIL 
1396  */
1397 #ifdef ANSI
1398 PRIVATE S16 rlcLmmCfgCkwSap 
1399 (
1400 RlcCb       *gCb,
1401 RlcSapCfg   *cfg             
1402 )
1403 #else
1404 PRIVATE S16 rlcLmmCfgCkwSap(gCb,cfg)
1405 RlcCb       *gCb;
1406 RlcSapCfg   *cfg;             
1407 #endif
1408 {
1409    RlcCkwSapCb  *ckwSap;
1410    
1411    TRC2(rlcLmmCfgCkwSap)
1412
1413 #if (ERRCLASS & ERRCLS_INT_PAR)
1414    /* Validate config parameters */
1415    if ((cfg->sapId >= RLC_MAX_CKWSAPS) || (cfg->sapId < 0) )
1416    {
1417       return (LCM_REASON_INVALID_PAR_VAL);
1418    }
1419
1420    if (gCb->genCfg.rlcMode == LKW_RLC_MODE_DL)
1421    {
1422       /* Get Sap control block */
1423       return (LCM_REASON_INVALID_PAR_VAL);
1424    }
1425 #endif
1426
1427    ckwSap = &(gCb->u.ulCb->ckwSap);
1428
1429 #if (ERRCLASS & ERRCLS_INT_PAR)
1430    /* Check for reconfiguration */
1431    if(ckwSap->state  != RLC_SAP_NOT_CFG)
1432    {
1433       RLOG1(L_ERROR,"Invalid rlckwuSap State [%d]",ckwSap->state);
1434       return (LCM_REASON_RECONFIG_FAIL);
1435    }
1436 #endif /* ERRCLASS & ERRCLS_INT_PAR */
1437    
1438    /* Fill the parameters */
1439    RLC_FILL_SAP_HELPER(ckwSap, cfg, gCb);
1440
1441    return (LCM_REASON_NOT_APPL);
1442
1443
1444 /**
1445  * @brief
1446  *    This function configures the UDX sap
1447  *
1448  * @param[in]  gCb   RLC Instance Control Block
1449  * @param[in]  cfg   RLC LM Sap configuration structure
1450  *
1451  * @return  S16
1452  *    -# LCM_REASON_NOT_APPL   (SUCCESS)
1453  *    -# LCM_REASON_INVALID_SAP
1454  *    -# LCM_REASON_INVALID_SAP
1455  *    -# LCM_REASON_RECONFIG_FAIL
1456  */
1457 #ifdef ANSI
1458 PRIVATE S16 rlcLmmCfgUdxSap 
1459 (
1460 RlcCb       *gCb,
1461 RlcSapCfg   *cfg         
1462 )
1463 #else
1464 PRIVATE S16 rlcLmmCfgUdxSap(gCb,cfg)
1465 RlcCb       *gCb;
1466 RlcSapCfg   *cfg;       
1467 #endif
1468 {
1469    RlcUdxDlSapCb   *udxDlSap;
1470    RlcUdxUlSapCb   *udxUlSap;
1471
1472    TRC2(rlcLmmCfgUdxSap);
1473    
1474 #if (ERRCLASS & ERRCLS_INT_PAR)
1475    /* Validate the protocol parameters */
1476    if((cfg->sapId >= RLC_MAX_UDXSAPS) || (cfg->sapId < 0))
1477    {
1478       return (LCM_REASON_INVALID_PAR_VAL);
1479    }
1480 #endif
1481    /* Get Sap control block */
1482    if (gCb->genCfg.rlcMode == LKW_RLC_MODE_DL)
1483    {
1484       udxDlSap = (gCb->u.dlCb->udxDlSap + cfg->sapId);
1485 #if (ERRCLASS & ERRCLS_INT_PAR)
1486       /* Check for reconfiguration */
1487       if(udxDlSap->state != RLC_SAP_NOT_CFG)
1488       {
1489          RLOG1(L_ERROR,"Invalid udxDlSap State [%d]",udxDlSap->state);
1490          return (LCM_REASON_RECONFIG_FAIL);
1491       }
1492 #endif /* ERRCLASS & ERRCLS_INT_PAR */
1493
1494       /* Fill the parameters */
1495       RLC_FILL_SAP_HELPER(udxDlSap, cfg, gCb);
1496    }
1497    else
1498    {
1499       udxUlSap = (gCb->u.ulCb->udxUlSap + cfg->sapId);
1500
1501 #if (ERRCLASS & ERRCLS_INT_PAR)
1502    /* Check for reconfiguration */
1503       if(udxUlSap->state != RLC_SAP_NOT_CFG)
1504       {
1505          RLOG1(L_ERROR,"Invalid udxUlSap State [%d]", udxUlSap->state);
1506          return (LCM_REASON_RECONFIG_FAIL);
1507       }
1508 #endif /* ERRCLASS & ERRCLS_INT_PAR */
1509
1510       /* Fill the parameters */
1511       RLC_FILL_SAP_HELPER(udxUlSap, cfg, gCb);
1512
1513       udxUlSap->bndTmrInt = cfg->bndTmrIntvl;
1514       udxUlSap->retryCnt = 0;
1515       cmInitTimers(&(udxUlSap->bndTmr), 1);
1516    }
1517
1518    return (LCM_REASON_NOT_APPL);
1519
1520
1521 /**
1522  * @brief
1523  *    This function configures the RGU sap
1524  *
1525  * @param[in]  gCb   RLC Instance Control Block
1526  * @param[in]  cfg   RLC LM Sap configuration structure
1527  * @return  S16
1528  *    -# LCM_REASON_NOT_APPL    (SUCCESS)
1529  *    -# LCM_REASON_INVALID_SAP
1530  *    -# LCM_REASON_INVALID_SAP
1531  *    -# LCM_REASON_RECONFIG_FAIL
1532  */
1533 #ifdef ANSI
1534 PRIVATE S16 rlcLmmCfgRguSap 
1535 (
1536 RlcCb       *gCb,
1537 RlcSapCfg   *cfg               
1538 )
1539 #else
1540 PRIVATE S16 rlcLmmCfgRguSap(gCb,cfg)
1541 RlcCb       *gCb;
1542 RlcSapCfg   *cfg;             
1543 #endif
1544 {
1545    RlcRguSapCb   *rguSap;
1546
1547    TRC2(rlcLmmCfgRguSap);
1548    
1549 #if (ERRCLASS & ERRCLS_INT_PAR)
1550    /* Validate the protocol parameters */
1551    if((cfg->sapId >= gCb->genCfg.maxRguSaps) || \
1552       (cfg->sapId < 0))
1553    {
1554       RLCLOGERROR(gCb,ERRCLS_INT_PAR, EKW047, (ErrVal)cfg->sapId,
1555                "rlcLmmCfgRguSap: Invalid RGU sapId\n");
1556       return (LCM_REASON_INVALID_PAR_VAL);
1557    }
1558 #endif
1559
1560    rguSap = (gCb->genCfg.rlcMode == LKW_RLC_MODE_DL) ?
1561             &(gCb->u.dlCb->rguDlSap[cfg->sapId]): &(gCb->u.ulCb->rguUlSap[cfg->sapId]);
1562
1563 #if (ERRCLASS & ERRCLS_INT_PAR)
1564    /* Check for reconfiguration */
1565    if(rguSap->state != RLC_SAP_NOT_CFG)
1566    {
1567       RLOG2(L_ERROR,"RLC Mode [%d]: Invalid rguSap State [%d]",
1568             gCb->genCfg.rlcMode, rguSap->state);
1569       return (LCM_REASON_RECONFIG_FAIL);
1570    }
1571 #endif /* ERRCLASS & ERRCLS_INT_PAR */
1572
1573    /* Fill the parameters */
1574    RLC_FILL_SAP_HELPER(rguSap, cfg, gCb);
1575    rguSap->suId = cfg->sapId;
1576    rguSap->bndTmrInt = cfg->bndTmrIntvl;
1577    rguSap->retryCnt = 0;
1578    rguSap->state = RLC_SAP_CFG;
1579
1580    cmInitTimers(&(rguSap->bndTmr), 1);
1581
1582    return (LCM_REASON_NOT_APPL);
1583
1584
1585 /**
1586  * @brief
1587  *    Validates the RLC general control parameters 
1588  *
1589  * @param[in] cntrl   RLC LM structure 
1590  * 
1591  * @return  S16
1592  *    -# LCM_REASON_NOT_APPL (SUCCESS)
1593  *    -# LCM_REASON_INVALID_SUBACTION
1594  *    -# LCM_REASON_INVALID_ACTION
1595  */
1596 #ifdef ANSI
1597 PRIVATE S16 rlcLmmValidateGenCntrl
1598 (
1599 RlcMngmt   *cntrl                 
1600 )
1601 #else
1602 PRIVATE S16 rlcLmmValidateGenCntrl(cntrl)
1603 RlcMngmt   *cntrl;                
1604 #endif
1605 {
1606    S16   reason;    /* reason for failure */
1607    U8    sAction;   /* subaction field */
1608
1609    TRC2(rlcLmmValidateGenCntrl);
1610
1611    reason = LCM_REASON_NOT_APPL;
1612    sAction = cntrl->t.cntrl.subAction;
1613
1614    switch (cntrl->t.cntrl.action)
1615    {
1616       case AENA:
1617       case ADISIMM:
1618          if ((sAction != SAUSTA) && 
1619              (sAction != SADBG) && 
1620              (sAction != SATRC))
1621          {
1622             reason = LCM_REASON_INVALID_SUBACTION;
1623          }
1624          break;
1625       case ASHUTDOWN:
1626          break;
1627       default:
1628          reason = LCM_REASON_INVALID_ACTION;
1629          break;
1630    }
1631    
1632    return (reason);
1633
1634
1635 /**
1636  * @brief
1637  *    it deregisters the timers and deregisters the rlckwuSap Control blocks 
1638  *
1639  * @param[in]  gCb   RLC Instance Control Block
1640  * 
1641  * @return  Void
1642  */
1643 #ifdef ANSI
1644 PRIVATE Void rlcLmmCleanGblRsrcs
1645 (
1646 RlcCb   *gCb
1647 )
1648 #else
1649 PRIVATE Void rlcLmmCleanGblRsrcs(gCb)
1650 RlcCb   *gCb;
1651 #endif
1652 {
1653    Size   rlcSapSize;
1654    Size   rlcUdxSapSize;
1655  
1656    TRC2(rlcLmmCleanGblRsrcs)   
1657  
1658    if (gCb->init.cfgDone)
1659    {
1660       /* Deregister the timers */
1661 /*Pradeep: changing the SDeregTmrMt() to SDeregTmr*/
1662       (Void) SDeregTmrMt(gCb->init.ent, gCb->init.inst,
1663                         (S16)gCb->genCfg.timeRes, rlcActvTmr);
1664       /*(Void) SDeregTmr(gCb->init.ent, gCb->init.inst,
1665                         (S16)gCb->genCfg.timeRes, rlcActvTmr);*/
1666
1667       rlcSapSize = (Size)(gCb->genCfg.maxKwuSaps * sizeof(RlcKwuSapCb));
1668
1669       if (gCb->genCfg.rlcMode == LKW_RLC_MODE_DL)
1670       {
1671          rlcUdxSapSize = (Size)(gCb->genCfg.maxUdxSaps * sizeof(RlcUdxDlSapCb));
1672          if (gCb->u.dlCb)
1673          {
1674             gCb->u.dlCb->shutdownReceived = TRUE;
1675             rlcUtlFreeDlMemory(gCb); 
1676             if (gCb->u.dlCb->rlcKwuDlSap != NULLP)
1677             {
1678                RLC_FREE(gCb,gCb->u.dlCb->rlcKwuDlSap, rlcSapSize);
1679             }
1680             
1681             if(gCb->u.dlCb->udxDlSap != NULLP)
1682             {
1683                RLC_FREE(gCb,gCb->u.dlCb->udxDlSap, rlcUdxSapSize);
1684             }
1685
1686             if(gCb->u.dlCb->rguDlSap != NULLP)
1687             {
1688                RLC_FREE(gCb,gCb->u.dlCb->rguDlSap, gCb->genCfg.maxRguSaps);
1689                gCb->genCfg.maxRguSaps = 0;
1690             }
1691              if (gCb->u.dlCb->shutdownReceived) 
1692             {
1693                if (gCb->u.dlCb->selfPstMBuf != NULL)
1694                {
1695                   SPutMsg(gCb->u.dlCb->selfPstMBuf);
1696                }
1697                RLC_FREE(gCb,gCb->u.dlCb, sizeof (RlcDlCb));
1698             }
1699          }
1700          
1701       }
1702       else
1703       {
1704          rlcUdxSapSize = (Size)(gCb->genCfg.maxUdxSaps * sizeof(RlcUdxUlSapCb));
1705          if (gCb->u.ulCb)
1706          {
1707             if (gCb->u.ulCb->rlcKwuUlSap != NULLP)
1708             {
1709                RLC_FREE(gCb,gCb->u.ulCb->rlcKwuUlSap, rlcSapSize);
1710             }
1711             
1712             if(gCb->u.ulCb->udxUlSap != NULLP)
1713             {
1714                RLC_FREE(gCb,gCb->u.ulCb->udxUlSap, rlcUdxSapSize);
1715             }
1716          
1717             if(gCb->u.ulCb->rguUlSap != NULLP)
1718             {
1719                RLC_FREE(gCb,gCb->u.ulCb->rguUlSap, gCb->genCfg.maxRguSaps);
1720                gCb->genCfg.maxRguSaps = 0;
1721             }
1722          
1723             RLC_FREE(gCb,gCb->u.ulCb, sizeof (RlcUlCb));
1724          }
1725       }
1726
1727       gCb->init.cfgDone = FALSE;
1728       gCb->init.acnt = FALSE;
1729       gCb->init.trc = FALSE;
1730
1731       gCb->init.usta = FALSE;
1732    }
1733
1734    RETVOID;
1735 }
1736
1737 /**
1738  * @brief
1739  *    Delete all SAPs and Control Blocks
1740  *
1741  * @details
1742  *    Shutdown of RLC happens at modules level, tm, um and am modules will be
1743  *    shutdown using utility functin and dbm shutdown will clean up the SAPs,
1744  *    control blocks and lists. 
1745  *
1746  * @params[in] gCb   RLC instance control block   
1747  *
1748  * @return  S16
1749  *    -# LCM_REASON_NOT_APPL (SUCCESS)
1750  *    -# LCM_REASON_HASHING_FAILED 
1751  */
1752 #ifdef ANSI
1753 PRIVATE S16 rlcLmmShutdown
1754 (
1755 RlcCb   *gCb
1756 )
1757 #else
1758 PRIVATE S16 rlcLmmShutdown(gCb)
1759 RlcCb   *gCb;
1760 #endif
1761 {
1762    RlcRguSapCb   *rguSap;
1763    U32          idx;
1764
1765    TRC2(rlcLmmShutdown)
1766
1767    if (gCb->genCfg.rlcMode == LKW_RLC_MODE_DL)
1768    {
1769       for (idx = 0; idx < gCb->genCfg.maxRguSaps; idx++)
1770       {
1771          rguSap = &(gCb->u.dlCb->rguDlSap[idx]);
1772          if ((rguSap->state == RLC_SAP_BND) || (rguSap->state == RLC_SAP_BINDING))
1773          {
1774             RlcLiRguUbndReq(&(rguSap->pst), rguSap->spId, 0);
1775          }
1776       }
1777    }
1778    else
1779    {
1780       for (idx = 0; idx < gCb->genCfg.maxRguSaps; idx++)
1781       {
1782          rguSap = &(gCb->u.ulCb->rguUlSap[idx]); 
1783          if ((rguSap->state == RLC_SAP_BND) || (rguSap->state == RLC_SAP_BINDING))
1784          {
1785             RlcLiRguUbndReq(&(rguSap->pst), rguSap->spId, 0);
1786          }
1787       }
1788    }
1789    
1790    if(gCb->genCfg.rlcMode == LKW_RLC_MODE_DL)
1791    {
1792       rlcDbmDlShutdown(gCb); 
1793    }
1794    else
1795    {
1796       rlcDbmUlShutdown(gCb);
1797    }
1798
1799    rlcLmmCleanGblRsrcs(gCb);
1800
1801    RLC_MEM_SET (&(gCb->genSts), 0, sizeof (RlcGenSts));
1802
1803    return (LCM_REASON_NOT_APPL);
1804
1805
1806 /**
1807  * @brief
1808  *    Function processes the general control request 
1809  *
1810  * @param[in] gCb     RLC instance control block
1811  * @param[in] cntrl   RLC LM structure
1812  *
1813  * @return  S16
1814  *    -# LCM_REASON_NOT_APPL (SUCCESS)
1815  *    -# LCM_REASON_INVALID_SUBACTION
1816  *    -# LCM_REASON_INVALID_ACTION
1817  */
1818 #ifdef ANSI
1819 PRIVATE S16 rlcLmmGenCntrl
1820 (
1821 RlcCb *gCb,
1822 RlcMngmt *cntrl       
1823 )
1824 #else
1825 PRIVATE S16 rlcLmmGenCntrl(gCb,cntrl)
1826 RlcCb    *gCb;
1827 RlcMngmt *cntrl;     
1828 #endif
1829 {
1830    RlcTrcCntrl *trcCntrl; /* trace */
1831 #ifdef DEBUGP
1832    RlcDbgCntrl *dbgCntrl; /* debug */
1833 #endif /* DEBUGP */
1834    S16   reason;         /* reason for failure */
1835    
1836    TRC2(rlcLmmGenCntrl);
1837
1838    /* Validate control parameters */
1839    reason = rlcLmmValidateGenCntrl (cntrl);
1840
1841    if (reason != LCM_REASON_NOT_APPL)
1842    {
1843       return (reason);
1844    }
1845
1846    switch(cntrl->t.cntrl.action)
1847    {
1848       case AENA:
1849       {
1850          switch(cntrl->t.cntrl.subAction)
1851          {
1852             case SAUSTA:
1853             {
1854                RLC_SET_USTA_FLAG(gCb, TRUE);
1855                break;
1856             }
1857             case SADBG:
1858             {
1859 #ifdef DEBUGP
1860                dbgCntrl = &cntrl->t.cntrl.s.dbgCntrl;
1861                RLC_GET_DBG_MASK(gCb) |= dbgCntrl->dbgMask;
1862 #endif /* DEBUGP */
1863                break;
1864             }
1865             case SATRC:
1866             {
1867                trcCntrl = &cntrl->t.cntrl.s.trcCntrl;
1868                gCb->init.trc = TRUE;
1869                gCb->trcLen = trcCntrl->trcLen;
1870                (gCb->trcMask) |= trcCntrl->trcMask;
1871                 break;
1872             }
1873          }
1874          break;
1875       }
1876       case ADISIMM:
1877       {
1878          switch(cntrl->t.cntrl.subAction)
1879          {
1880             case SAUSTA:
1881             {
1882                gCb->init.usta = FALSE;
1883             }
1884             break;
1885             case SADBG:
1886             {
1887 #ifdef DEBUGP
1888                dbgCntrl = &cntrl->t.cntrl.s.dbgCntrl;
1889                RLC_GET_DBG_MASK(gCb) &= ~(dbgCntrl->dbgMask);
1890 #endif /* DEBUGP */
1891             }
1892             break;
1893             case SATRC:
1894             {
1895                trcCntrl = &cntrl->t.cntrl.s.trcCntrl;
1896                gCb->init.trc = FALSE;
1897                gCb->trcMask &= ~(trcCntrl->trcMask);
1898             }
1899             break;
1900          }
1901          break;
1902       }
1903       case ASHUTDOWN:
1904       {
1905          reason = rlcLmmShutdown(gCb);
1906          break;
1907       }
1908    }
1909    return (reason);
1910
1911
1912 /**
1913  * @brief
1914  *    Bind/Unbind RLC UDX sap 
1915  *
1916  * @param[in]  gCb     RLC Instance Control Block
1917  * @param[in]  cntrl   RLC LM structure
1918  * 
1919  * @return  S16
1920  *    -# LCM_REASON_NOT_/PPL (SUCCESS)    
1921  *    -# LCM_REASON_INVALID_SAP 
1922  *    -# LCM_REASON_INVALID_STATE
1923  *    -# LCM_REASON_INVALID_ACTION 
1924  */
1925 #ifdef ANSI
1926 PRIVATE S16 rlcLmmUdxSapCntrl
1927 (
1928 RlcCb      *gCb,
1929 RlcMngmt   *cntrl               
1930 )
1931 #else
1932 PRIVATE S16 rlcLmmUdxSapCntrl(gCb,cntrl)
1933 RlcCb      *gCb;
1934 RlcMngmt   *cntrl;               
1935 #endif
1936 {
1937    TRC2(rlcLmmUdxSapCntrl)
1938
1939 #if (ERRCLASS & ERRCLS_INT_PAR)
1940    if (gCb->genCfg.rlcMode == LKW_RLC_MODE_DL)
1941    {
1942       return (LCM_REASON_INVALID_SAP);
1943    }
1944    /* validate SuId */
1945    if((cntrl->t.cntrl.s.sapCntrl.suId < 0) || 
1946       (cntrl->t.cntrl.s.sapCntrl.suId >= RLC_MAX_UDXSAPS))
1947    {
1948       return (LCM_REASON_INVALID_SAP);
1949    }
1950 #endif /* ERRCLASS & ERRCLS_INT_PAR */
1951
1952 #define UDX_SAP  gCb->u.ulCb->udxUlSap[cntrl->t.cntrl.s.sapCntrl.suId]
1953 #if (ERRCLASS & ERRCLS_INT_PAR)
1954    /* validate SAP */
1955    if(UDX_SAP.state == RLC_SAP_NOT_CFG)
1956    {
1957       RLOG0(L_ERROR,"udxUlSap not configured yet");
1958       return (LCM_REASON_INVALID_STATE);
1959    }
1960 #endif /* ERRCLASS & ERRCLS_INT_PAR */
1961
1962    switch(cntrl->t.cntrl.action)
1963    {
1964       case ABND:
1965       {
1966          if(UDX_SAP.state != RLC_SAP_BND)
1967          {
1968             /* start timer to wait for bind confirm */
1969             rlcStartTmr(gCb,(PTR)(&UDX_SAP), RLC_EVT_WAIT_BNDCFM);
1970             UDX_SAP.state = RLC_SAP_BINDING;
1971             rlcUlUdxBndReq(&(UDX_SAP.pst), UDX_SAP.suId, UDX_SAP.spId);
1972          }
1973          else
1974          {
1975             /* control request received for an already bound SAP */
1976             return (LCM_REASON_INVALID_STATE);
1977          }
1978       }
1979       break;
1980       case AUBND:
1981       {
1982          /* make the state of UDXSAP configured but not bound */
1983          UDX_SAP.state = RLC_SAP_CFG;
1984          rlcUlUdxUbndReq(&(UDX_SAP.pst), UDX_SAP.spId, 0);
1985       }
1986       break;
1987       default:
1988          return (LCM_REASON_INVALID_ACTION);
1989          break;
1990    } /* end of switch */
1991 #undef UDX_SAP
1992    return (LCM_REASON_NOT_APPL);
1993
1994
1995 /**
1996  * @brief
1997  *    Bind/Unbind RLC lower sap 
1998  *
1999  * @param[in]  gCb     RLC Instance Control Block
2000  * @param[in]  cntrl   RLC LM structure
2001  * @return  S16
2002  *    -# LCM_REASON_NOT_APPL       (SUCCESS)
2003  *    -# LCM_REASON_INVALID_SAP 
2004  *    -# LCM_REASON_INVALID_STATE
2005  *    -# LCM_REASON_INVALID_ACTION 
2006  */
2007 #ifdef ANSI
2008 PRIVATE S16 rlcLmmLSapCntrl
2009 (
2010 RlcCb      *gCb,
2011 RlcMngmt   *cntrl 
2012 )
2013 #else
2014 PRIVATE S16 rlcLmmLSapCntrl(gCb,cntrl)
2015 RlcCb      *gCb;
2016 RlcMngmt   *cntrl; 
2017 #endif
2018 {
2019    RlcRguSapCb   *rguSap;   /* rgu sap pointer */
2020
2021    TRC2(rlcLmmLSapCntrl)
2022
2023 #if (ERRCLASS & ERRCLS_INT_PAR)
2024    /* validate SuId */
2025    if((cntrl->t.cntrl.s.sapCntrl.suId < 0) || 
2026       (cntrl->t.cntrl.s.sapCntrl.suId >= gCb->genCfg.maxRguSaps))
2027    {
2028       RLCLOGERROR(gCb,ERRCLS_INT_PAR, EKW047, (ErrVal)cntrl->t.cntrl.s.sapCntrl.suId,
2029                "rlcLmmLSapCntrl: Invalid RGU suId\n");
2030       return (LCM_REASON_INVALID_SAP);
2031    }
2032 #endif /* ERRCLASS & ERRCLS_INT_PAR */
2033    rguSap = (gCb->genCfg.rlcMode == LKW_RLC_MODE_DL) ?
2034             &(gCb->u.dlCb->rguDlSap[cntrl->t.cntrl.s.sapCntrl.suId]): \
2035             &(gCb->u.ulCb->rguUlSap[cntrl->t.cntrl.s.sapCntrl.suId]);
2036
2037 #if (ERRCLASS & ERRCLS_INT_PAR)
2038    /* validate SAP */
2039    if(rguSap->state == RLC_SAP_NOT_CFG)
2040    {
2041       RLOG1(L_ERROR,"RLC Mode [%d]:rguSap not configured yet", gCb->genCfg.rlcMode);
2042       return (LCM_REASON_INVALID_STATE);
2043    }
2044 #endif /* ERRCLASS & ERRCLS_INT_PAR */
2045
2046    switch(cntrl->t.cntrl.action)
2047    {
2048       case ABND:
2049       {
2050          if(rguSap->state != RLC_SAP_BND)
2051          {
2052             /* start timer to wait for bind confirm */
2053             rlcStartTmr(gCb,(PTR)(rguSap), RLC_EVT_WAIT_BNDCFM);
2054             rguSap->state = RLC_SAP_BINDING;
2055             rguSap->spId = cntrl->t.cntrl.s.sapCntrl.spId;
2056             rguSap->suId = cntrl->t.cntrl.s.sapCntrl.suId;
2057             RlcLiRguBndReq(&(rguSap->pst), rguSap->suId, rguSap->spId);
2058          }
2059          else
2060          {
2061             /* control request received for an already bound SAP */
2062             return (LCM_REASON_INVALID_STATE);
2063          }
2064       }
2065       break;
2066       case AUBND:
2067       {
2068          /* make the state of RGUSAP is configure but not bound */
2069          rguSap->state = RLC_SAP_CFG;
2070          RlcLiRguUbndReq(&(rguSap->pst), rguSap->spId, 0);
2071       }
2072       break;
2073       default:
2074          return (LCM_REASON_INVALID_ACTION);
2075          break;
2076    } /* end of switch */
2077
2078    return (LCM_REASON_NOT_APPL);
2079
2080
2081 /**
2082  * @brief
2083  *    Function gather the general KWU SAP status 
2084  *
2085  * @param[in] gCb   RLC Instance Control Block
2086  * @param[in] sta   LM KWU Sap Status structure 
2087  * 
2088  * @return  S16
2089  *    -# LCM_REASON_NOT_APPL       (SUCCESS)
2090  *    -# LCM_REASON_INVALID_PAR_VAL(FAILURE)
2091  */
2092 #ifdef ANSI
2093 PRIVATE S16 rlcLmmGetKwuSapSta 
2094 (
2095 RlcCb          *gCb,
2096 RlcKwuSapSta   *sta         
2097 )
2098 #else
2099 PRIVATE S16 rlcLmmGetKwuSapSta(gCb,sta)
2100 RlcCb          *gCb;
2101 RlcKwuSapSta   *sta;         
2102 #endif
2103 {
2104    RlcKwuSapCb   *rlcKwSapCb;
2105    
2106    TRC2(rlcLmmGetKwuSapSta);
2107
2108 #if (ERRCLASS & ERRCLS_INT_PAR)
2109    /* Validate the protocol parameters */
2110    if ((sta->spId >= (S16)gCb->genCfg.maxKwuSaps)||
2111        (sta->spId < 0))
2112    {
2113       return (LCM_REASON_INVALID_PAR_VAL);
2114    }
2115 #endif
2116
2117    /* Get Sap control block */
2118    rlcKwSapCb = (gCb->genCfg.rlcMode == LKW_RLC_MODE_DL)? 
2119              (RlcKwuSapCb*)(gCb->u.dlCb->rlcKwuDlSap + sta->spId):
2120              (RlcKwuSapCb*)(gCb->u.ulCb->rlcKwuUlSap + sta->spId);
2121
2122    sta->state = rlcKwSapCb->state;
2123
2124    return (LCM_REASON_NOT_APPL);
2125
2126
2127 /**
2128  * @brief
2129  *    Function gather the general RGU SAP status
2130  *
2131  * @param[in]  gCb   RLC Instance Control Block
2132  * @param[in]  sta   LM RGU Sap Status structure
2133  * @return  S16
2134  *    -# LCM_REASON_NOT_APPL       (SUCCESS) 
2135  *    -# LCM_REASON_INVALID_PAR_VAL(FAILURE) 
2136  */
2137 #ifdef ANSI
2138 PRIVATE S16 rlcLmmGetRguSapSta 
2139 (
2140 RlcCb          *gCb,
2141 RlcRguSapSta   *sta         
2142 )
2143 #else
2144 PRIVATE S16 rlcLmmGetRguSapSta(gCb,sta)
2145 RlcCb          *gCb;
2146 RlcRguSapSta   *sta;       
2147 #endif
2148 {
2149    TRC2(rlcLmmGetRguSapSta);
2150
2151 #if (ERRCLASS & ERRCLS_INT_PAR)
2152    /* Validate the protocol parameters */
2153    if((sta->suId >= RLC_MAX_RGUSAPS) || (sta->suId < 0))
2154    {
2155       return (LCM_REASON_INVALID_PAR_VAL);
2156    }
2157 #endif
2158
2159    sta->state = (gCb->genCfg.rlcMode == LKW_RLC_MODE_DL) ? 
2160                  gCb->u.dlCb->rguDlSap[sta->suId].state : 
2161                  gCb->u.ulCb->rguUlSap[sta->suId].state ;
2162
2163    return (LCM_REASON_NOT_APPL);
2164
2165
2166 /**
2167  * @brief
2168  *    Function gather the general CKW SAP status
2169  *
2170  * @param[in]  gCb   RLC Instance Control Block
2171  * @param[in]  sta   LM CKW Sap Status structure
2172  * @return  S16
2173  *    -# LCM_REASON_NOT_APPL       (SUCCESS)
2174  *    -# LCM_REASON_INVALID_PAR_VAL(FAILURE)
2175  */
2176 #ifdef ANSI
2177 PRIVATE S16 rlcLmmGetCkwCntSapSta
2178 (
2179 RlcCb             *gCb,
2180 RlcCkwCntSapSta   *sta     
2181 )
2182 #else
2183 PRIVATE S16 rlcLmmGetCkwCntSapSta(gCb,sta)
2184 rlcCb             *gCb,
2185 RlcCkwCntSapSta   *sta;   
2186 #endif
2187 {
2188    TRC2(rlcLmmGetCkwCntSapSta);
2189
2190 #if (ERRCLASS & ERRCLS_INT_PAR)
2191    /* Validate config parameters */
2192    if ((sta->spId >= RLC_MAX_CKWSAPS ) ||
2193        (sta->spId < 0 ) ||
2194        (gCb->genCfg.rlcMode == LKW_RLC_MODE_DL))
2195    {
2196       return (LCM_REASON_INVALID_PAR_VAL);
2197    }
2198 #endif
2199    sta->state =  gCb->u.ulCb->ckwSap.state;
2200
2201    return (LCM_REASON_NOT_APPL);
2202
2203
2204
2205 /**
2206  * @brief
2207  *    Gather the general statistics 
2208  *
2209  * @param[in]  gCb      RLC Instance Control Block
2210  * @param[in]  sts      LM general statistics structure
2211  * @param[in]  action   action
2212  * @return  S16
2213  *    -# LCM_REASON_NOT_APPL       (SUCCESS)
2214  *    -# LCM_REASON_INVALID_PAR_VAL(FAILURE)
2215  */
2216 #ifdef ANSI
2217 PRIVATE S16 rlcLmmGetGenSts
2218 (
2219 RlcCb       *gCb,
2220 RlcGenSts   *sts,       
2221 Action     action         
2222 )
2223 #else
2224 PRIVATE S16 rlcLmmGetGenSts(gCb,sts, action)
2225 RlcCb       *gCb;
2226 RlcGenSts   *sts;          
2227 Action     action;         
2228 #endif
2229 {
2230    TRC2(rlcLmmGetGenSts);
2231
2232 #if (ERRCLASS & ERRCLS_INT_PAR)
2233    /* Validate protocol parameters */
2234    if ((action != LKW_ZEROSTS) && (action != LKW_NOZEROSTS))
2235    {
2236       return (LCM_REASON_INVALID_PAR_VAL);
2237    }
2238 #endif
2239
2240    *sts = gCb->genSts;
2241    
2242    if(action == LKW_ZEROSTS)
2243    {
2244       RLC_MEM_SET (&(gCb->genSts), 0, sizeof (RlcGenSts));
2245    }
2246
2247    return (LCM_REASON_NOT_APPL);
2248
2249
2250 /**
2251  * @brief
2252  *    Gather the SAP statistics
2253  *
2254  * @param[in]  gCb      RLC Instance Control Block
2255  * @param[in]  sts      LM general statistics structure
2256  * @param[in]  elmnt    element 
2257  * @param[in]  action   action 
2258  * 
2259  * @return  S16
2260  *    -# LCM_REASON_NOT_APPL (SUCCESS)
2261  *    -# LCM_REASON_INVALID_PAR_VAL (FAIL)
2262  */
2263 #ifdef ANSI
2264 PRIVATE S16 rlcLmmGetSapSts
2265 (
2266 RlcCb      *gCb,
2267 RlcMngmt   *sts,               
2268 Elmnt     elmnt,               
2269 Action    action             
2270 )
2271 #else
2272 PRIVATE S16 rlcLmmGetSapSts(sts, elmnt, action)
2273 RlcCb      *gCb;
2274 RlcMngmt   *sts;            
2275 Elmnt     elmnt;            
2276 Action    action;         
2277 #endif
2278 {
2279    TRC2(rlcLmmGetSapSts);
2280
2281    /* Validate protocol parameters */
2282    if (action != LKW_ZEROSTS && action != LKW_NOZEROSTS)
2283    {
2284       return (LCM_REASON_INVALID_PAR_VAL);
2285    }
2286    switch(elmnt)
2287    {
2288       case STKWUSAP:
2289       {
2290          RlcKwuSapSts  *rlckwuSap; 
2291          RlcKwuSapCb   *rlcKwuSapCb;    
2292          rlckwuSap = &sts->t.sts.s.rlckwuSap;
2293
2294          /* Get Sap control block */
2295          /* kw005.201, modified the element of rlckwuSap from suId to spId */
2296          rlcKwuSapCb = (gCb->genCfg.rlcMode == LKW_RLC_MODE_DL)? 
2297               (RlcKwuSapCb*)(gCb->u.dlCb->rlcKwuDlSap + rlckwuSap->spId):
2298               (RlcKwuSapCb*)(gCb->u.ulCb->rlcKwuUlSap + rlckwuSap->spId);
2299
2300
2301          *rlckwuSap = rlcKwuSapCb->sts;
2302
2303          if (action == LKW_ZEROSTS)
2304          {
2305             RLC_MEM_SET (&rlcKwuSapCb->sts, 0, sizeof (RlcKwuSapSts));
2306          }
2307          break;
2308       }
2309       /* kw005.201 removed RGUSAP statistics support */
2310       case STCKWSAP:
2311       {
2312          RlcCkwCntSts  *ckwSap;  
2313          ckwSap = &sts->t.sts.s.ckwSap;
2314          if (gCb->genCfg.rlcMode == LKW_RLC_MODE_DL) 
2315          {
2316             return (LCM_REASON_INVALID_PAR_VAL);
2317          }
2318
2319          ckwSap->statMsgs = gCb->u.ulCb->ckwSap.sts.statMsgs;
2320
2321          if (action == LKW_ZEROSTS)
2322          {
2323             RLC_MEM_SET (&(gCb->u.ulCb->ckwSap.sts), 0, sizeof (RlcCkwCntSts));
2324          }
2325          break;
2326       }
2327       default:
2328          return (LCM_REASON_INVALID_ELMNT);
2329    }
2330
2331    SGetDateTime(&sts->t.sts.dt);
2332
2333    return (LCM_REASON_NOT_APPL);
2334
2335
2336 /**
2337  * @brief
2338  *    This function sends Unsolicited Status Indication to the Layer Management
2339  *    Entity. 
2340  *
2341  * @param[in]  gCb        RLC Instance Control Block
2342  * @param[in]  category   Category 
2343  * @param[in]  event      event
2344  * @param[in]  cause      cause
2345  * @param[in]  UeId       ueId 
2346  * @param[in]  Qci        qci 
2347  * 
2348  * @return  Void
2349  */
2350 #ifdef LTE_L2_MEAS
2351 #ifdef ANSI
2352 Void rlcLmmSendAlarm
2353 (
2354 RlcCb   *gCb,
2355 U16    category,  
2356 U16    event,    
2357 U16    cause,   
2358 SuId   suId,   
2359 U32    ueId,  
2360 U8     qci   
2361 )
2362 #else
2363 Void rlcLmmSendAlarm(category, event, cause, suId, ueId, qci)
2364 RlcCb   *gCb;
2365 U16    category; 
2366 U16    event;   
2367 U16    cause;  
2368 SuId   suId;  
2369 U32    ueId; 
2370 U8     qci;    
2371 #endif
2372 #else /* LTE_L2_MEAS */
2373 #ifdef ANSI
2374 Void rlcLmmSendAlarm
2375 (
2376 RlcCb   *gCb,
2377 U16    category, 
2378 U16    event,   
2379 U16    cause,  
2380 SuId   suId,  
2381 U32    ueId  
2382 )
2383 #else
2384 Void rlcLmmSendAlarm(category, event, cause, suId, ueId)
2385 RlcCb   *gCb;
2386 U16    category; 
2387 U16    event;   
2388 U16    cause;  
2389 SuId   suId;  
2390 U32    ueId; 
2391 #endif
2392 #endif /* LTE_L2_MEAS */
2393 {
2394    RlcMngmt   usta;   /* Rlc Management Structure */
2395
2396    TRC2(rlcLmmSendAlarm);
2397
2398    if(gCb->init.usta == FALSE)
2399    {
2400       RETVOID;
2401    }
2402
2403    usta.hdr.elmId.elmnt = STGEN;
2404    usta.hdr.entId.ent = gCb->init.ent;
2405    usta.hdr.entId.inst = gCb->init.inst;
2406
2407    /* fill in the event and category */
2408    usta.t.usta.alarm.category = category;
2409    usta.t.usta.alarm.event = event;
2410    usta.t.usta.alarm.cause = cause;
2411
2412    /* set the suId and ueId */
2413    usta.t.usta.ueId = ueId;
2414    usta.t.usta.suId = suId;
2415 /* kw005.201 added support for L2 Measurement */
2416 #ifdef LTE_L2_MEAS
2417    if(event == LKW_EVT_MEAS_HALT)
2418    {
2419       usta.t.usta.qci = qci;
2420    }
2421 #endif /* LTE_L2_MEAS */
2422    /* update the date and time */
2423    (Void) SGetDateTime(&usta.t.usta.alarm.dt);
2424
2425    RlcMiLkwStaInd(&(gCb->init.lmPst), &usta);
2426
2427    RETVOID;
2428
2429
2430
2431 /**
2432  * @brief
2433  *    This function sends trace indication to LM 
2434  *
2435  * @param[in]  gCb     RLC Instance Control Block
2436  * @param[in]  event   event
2437  * @param[in]  mBuf    meessage buffer
2438  *
2439  * @return S16
2440  *    -# ROK 
2441  *    -# RFAILED 
2442  */
2443 #ifdef ANSI
2444 S16 rlcLmmSendTrc
2445 (
2446 RlcCb     *gCb,
2447 Event    event,     
2448 Buffer   *mBuf     
2449 )
2450 #else
2451 S16 rlcLmmSendTrc(gCb,event, mBuf)
2452 RlcCb     *gCb;
2453 Event    event;   
2454 Buffer   *mBuf;  
2455 #endif
2456 {
2457    RlcMngmt   trc;              /* RLC management control block */
2458    Buffer    *dstMbuf;   
2459    MsgLen    bufLen;
2460    Data      *tempBuf;
2461    MsgLen    tempCnt;
2462    Pst       pst;
2463
2464    TRC2(rlcLmmSendTrc)
2465
2466    RLOG2(L_DEBUG, "rlcLmmSendTrc(): Trace for event=%d, gCb->trcLen=%d",
2467                      event,
2468                      gCb->trcLen);
2469
2470    cmMemset((U8 *)&trc, 0, sizeof(RlcMngmt));
2471
2472    pst = gCb->init.lmPst;
2473
2474    trc.t.trc.event = event;
2475    SGetDateTime(&trc.t.trc.dt);
2476    trc.cfm.status = LCM_PRIM_OK;
2477    trc.cfm.reason = LCM_REASON_NOT_APPL;
2478          
2479    if(mBuf != NULLP)
2480    {
2481      /* Check if the whole buffer is to be sent in Trace indication */
2482      if(gCb->trcLen == LKW_FULL_TRACE)
2483      {
2484         if (SCpyMsgMsg(mBuf, pst.region, pst.pool, &dstMbuf)
2485             != ROK)
2486         {
2487            /* rg005.201 removed SPutSBuf on error */
2488            RLOG0(L_ERROR,"SCpyMsgMsg Failed");   
2489            return RFAILED;
2490         }
2491         /* Send Trace Indication to Layer manager */
2492         RlcMiLkwTrcInd(&pst, &trc, dstMbuf);
2493      }
2494      /* check if only a specified number of bytes are to be sent */
2495      else if(gCb->trcLen > 0)
2496      {
2497         /* Get the length of the recvd message buffer */
2498         if (SFndLenMsg(mBuf, &bufLen) != ROK)
2499         {
2500            RLOG0(L_ERROR,"SFndLenMsg Failed");   
2501            return RFAILED;
2502         }
2503         /* Check if the recvd buffer size is less than request trace len */
2504         if(bufLen < gCb->trcLen)
2505         {
2506            /* Copy the whole of the recvd buffer in trace indication */
2507       
2508            if (SCpyMsgMsg(mBuf, pst.region, pst.pool, &dstMbuf)
2509               != ROK)
2510            {
2511               RLOG0(L_ERROR,"SCpyMsgMsg Failed");   
2512               return RFAILED;
2513            }
2514          
2515            /* Send Trace Indication to Layer manager */
2516            RlcMiLkwTrcInd(&pst, &trc, dstMbuf);
2517         }
2518         else
2519         {
2520            /* if the recvd buffer size is greater than request trace len */
2521            /* Get a temporary buffer to store the msg */
2522            RLC_ALLOC(gCb,tempBuf, gCb->trcLen);
2523
2524 #if (ERRCLASS & ERRCLS_INT_PAR)
2525            if(tempBuf == NULLP)
2526            {
2527               (Void) SPutSMem(RLC_GET_MEM_REGION(gCb), RLC_GET_MEM_POOL(gCb));
2528       
2529                RLOG0(L_FATAL,"Memory Allocation failed");   
2530                return (LCM_REASON_MEM_NOAVAIL);
2531            }
2532 #endif /* ERRCLASS & ERRCLS_INT_PAR */
2533          
2534            /* Copy trcLen nos of bytes from the recvd message */
2535            if (SCpyMsgFix(mBuf,0,gCb->trcLen,tempBuf,&tempCnt) != ROK)   
2536            {
2537               RLOG0(L_ERROR,"SCpyMsgFix Failed");   
2538               return RFAILED;
2539            }
2540
2541            if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
2542            {
2543               RLOG0(L_FATAL,"Memory Allocation failed");   
2544               return RFAILED;
2545            }
2546            /* Copy the tempBuf data to dst mBuf */
2547            if (SCpyFixMsg(tempBuf,dstMbuf,0,gCb->trcLen,&tempCnt) != ROK)
2548            {
2549               RLOG0(L_ERROR,"SCpyMsgFix Failed");   
2550               return RFAILED;
2551            }
2552   
2553            /* Free the memory allocated for tempBuf */
2554            RLC_FREE(gCb,tempBuf, gCb->trcLen);
2555            /* Send Trace Indication to Layer manager */
2556            RlcMiLkwTrcInd(&pst, &trc, dstMbuf);
2557         }
2558      }
2559    }
2560    else
2561    {
2562       RlcMiLkwTrcInd(&pst, &trc, mBuf);
2563    }
2564
2565    return ROK;
2566
2567
2568 \f  
2569 /*
2570  * @brief
2571  *    Activate Task - timer
2572  *
2573  * @details     
2574  *    Invoked by system services to activate a task with a timer tick.
2575  *
2576  * @param[in] ent    entity
2577  * @param[in] inst   instance
2578  *
2579  * @return S16
2580  *    -# ROK
2581  *    -# RFAILED
2582  *
2583  */
2584  
2585 #ifdef ANSI
2586 S16 rlcActvTmr
2587 (
2588 Ent    ent,
2589 Inst   inst
2590 )
2591 #else
2592 S16 rlcActvTmr(ent,inst)
2593 Ent    ent;
2594 Inst   inst;
2595 #endif
2596 {
2597    RlcCb   *gCb; 
2598    TRC2(rlcActvTmr)
2599
2600    if (inst >= MAX_RLC_INSTANCES)
2601    {
2602       return  (RFAILED);
2603    }
2604    gCb = RLC_GET_RLCCB(inst); 
2605    cmPrcTmr(&(gCb->rlcTqCp), gCb->rlcTq, (PFV) rlcTmrExpiry);
2606    return (ROK);
2607
2608 } /* end of rlcActvTmr */
2609
2610  
2611 /********************************************************************30**
2612
2613          End of file
2614 **********************************************************************/