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