9ba4f88609bf5ba846cecaa6129ce350ef400cab
[o-du/l2.git] / src / 5gnrrlc / kw_udx_dl.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18
19 /**********************************************************************
20  
21     Name:   LTE RLC layer
22  
23     Type:   C include file
24  
25     Desc:   Defines required by LTE MAC
26  
27     File:   kw_udx_dl.c
28
29 **********************************************************************/
30 static const char* RLOG_MODULE_NAME="UDX";
31 static int RLOG_MODULE_ID=262144;
32 static int RLOG_FILE_ID=203;
33
34 /* header include files (.h) */
35 #include "envopt.h"        /* environment options */
36 #include "envdep.h"        /* environment dependent */
37 #include "envind.h"        /* environment independent */
38
39 #include "gen.h"           /* general */
40 #include "ssi.h"           /* system services */
41 #include "cm5.h"           /* common timer defines */
42 #include "cm_tkns.h"       /* common tokens defines */
43 #include "cm_mblk.h"       /* common memory allocation library defines */
44 #include "cm_llist.h"      /* common link list  defines  */
45 #include "cm_hash.h"       /* common hash list  defines */
46 #include "cm_lte.h"        /* common LTE defines */
47 #include "lkw.h"           /* LKW defines */
48 #include "ckw.h"           /* CKW defines */
49 #include "kwu.h"           /* KWU defines */
50 #include "rgu.h"           /* RGU defines */
51 #include "kw_err.h"        /* Err defines */
52 #include "kw_env.h"        /* RLC environment options */
53
54 #include "kw.h"            /* RLC defines */
55 #include "kw_udx.h"
56 #include "kw_dl.h"
57
58 /* extern (.x) include files */
59 #include "gen.x"           /* general */
60 #include "ssi.x"           /* system services */
61
62 #include "cm5.x"           /* common timer library */
63 #include "cm_tkns.x"       /* common tokens */
64 #include "cm_mblk.x"       /* common memory allocation */
65 #include "cm_llist.x"      /* common link list */
66 #include "cm_hash.x"       /* common hash list */
67 #include "cm_lte.x"        /* common LTE includes */
68 #include "cm_lib.x"        /* common memory allocation library */
69 #include "lkw.x"           /* LKW */
70 #include "ckw.x"           /* CKW */
71 #include "kwu.x"           /* KWU */
72 #include "rgu.x"           /* RGU */
73
74 #include "kw.x"
75 #include "kw_udx.x"
76 #include "kw_dl.x"
77
78
79 #define KW_MODULE KW_DBGMASK_UDX
80 /* local defines */
81
82 EXTERN S16 kwDlmHndlStaRsp ARGS (( KwCb  *gCb,KwDlRbCb  *rbCb,
83                 KwUdxStaPdu *pStaPdu, KwUdxBufLst  *rlsPduLst));
84
85
86
87
88 /**
89   * @brief
90   * UDX APIs
91   */
92
93 /**
94  *
95  * @brief 
96  *    Handler to bind the DL with UL. 
97  *
98  * @param[in] pst   Post structure  
99  * @param[in] suId  Service user SAP ID 
100  * @param[in] spId  Service provider ID
101  *
102  * @return  S16
103  *    -# ROK 
104  *    -# RFAILED
105  */
106 #ifdef ANSI
107 PUBLIC S16 KwDlUdxBndReq 
108 (
109 Pst    *pst,  
110 SuId   suId, 
111 SpId   spId 
112 )
113 #else
114 PUBLIC S16 KwDlUdxBndReq (pst, suId, spId)
115 Pst    *pst;   
116 SuId   suId;  
117 SpId   spId; 
118 #endif
119 {
120    KwUdxDlSapCb   *udxSap;            /* pointer to session SAP */
121    KwCb           *tKwCb;
122
123    TRC3(KwDlUdxBndReq);
124
125 #if (ERRCLASS & ERRCLS_INT_PAR)
126    if (pst->dstInst >= KW_MAX_RLC_INSTANCES)
127    {
128       RETVALUE(RFAILED);
129    }
130 #endif
131    tKwCb = KW_GET_KWCB(pst->dstInst);
132
133    KWDBGP_BRIEF(tKwCb, "KwDlUdxBndReq(spId(%d), suId(%d))\n", 
134                 spId, suId);
135
136    udxSap = (tKwCb->u.dlCb->udxDlSap + spId);
137
138    /* Verify CKW SAP State */
139    switch(udxSap->state)
140    {
141       /* SAP is configured but not bound */
142       case KW_SAP_CFG:
143       case KW_SAP_UBND:
144       {
145          /* copy bind configuration parameters in SSAP sap */
146          udxSap->suId = suId;
147          udxSap->pst.dstProcId = pst->srcProcId;
148          udxSap->pst.dstEnt = pst->srcEnt;
149          udxSap->pst.dstInst = pst->srcInst;
150
151          /* Update the State */
152          udxSap->state = KW_SAP_BND;
153
154          RLOG1(L_INFO, "UDX SAP state [%d]", udxSap->state);
155          break;
156       }
157       /* SAP is already bound */
158       case KW_SAP_BND:
159       {
160          /* 
161           * Sap is already bound check source, destination Entity and 
162           * Proc Id
163           */
164          if (udxSap->pst.dstProcId != pst->srcProcId 
165                || udxSap->pst.dstEnt != pst->srcEnt
166                || udxSap->pst.dstInst != pst->srcInst
167                || udxSap->suId != suId)
168          {
169             KW_SEND_SAPID_ALARM(tKwCb, spId, 
170                                 LKW_EVENT_UDX_BND_REQ, LCM_CAUSE_INV_PAR_VAL);
171
172             RLOG0(L_ERROR, "UDX SAP already Bound");
173             KwDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_NOK);
174          }
175          break;
176       }
177
178      default:
179       {
180 #if (ERRCLASS & ERRCLS_INT_PAR)
181          KW_SEND_SAPID_ALARM(tKwCb,spId, 
182                              LKW_EVENT_CKW_BND_REQ, LCM_CAUSE_INV_STATE);
183 #endif /* ERRCLASS & ERRCLS_INT_PAR */
184          RLOG0(L_ERROR, "Invalid UDX SAP State in Bind Req");
185          KwDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_NOK);
186          break;
187       }
188    }
189    KwDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_OK);
190    RETVALUE(ROK);
191
192
193 \f
194 /**
195  * @brief 
196  *    Handler for unbinding the DL from UL. 
197  *
198  *  @param[in] pst     Post structure  
199  *  @param[in] spId    Service provider SAP ID 
200  *  @param[in] reason  Reason for Unbinding 
201  *
202  *  @return  S16
203  *      -# ROK 
204  */
205 #ifdef ANSI
206 PUBLIC S16 KwDlUdxUbndReq
207 (
208 Pst      *pst,    
209 SpId     spId,   
210 Reason   reason 
211 )
212 #else
213 PUBLIC S16 KwDlUdxUbndReq(pst, spId, reason)
214 Pst      *pst;   
215 SpId     spId;   
216 Reason   reason; 
217 #endif
218 {
219    KwUdxDlSapCb   *udxSap; 
220    KwCb           *tKwCb;
221
222    TRC3(KwDlUdxUbndReq)
223
224 #if (ERRCLASS & ERRCLS_INT_PAR)
225    if (pst->dstInst >= KW_MAX_RLC_INSTANCES)
226    {
227       RETVALUE(RFAILED);
228    }
229 #endif
230
231    tKwCb = KW_GET_KWCB(pst->dstInst);
232
233    RLOG2(L_DEBUG,"Unbind Req for spId[%d], reason[%d]", 
234                 spId, reason);
235    UNUSED(reason);
236    /* disable upper sap (CKW) */
237    udxSap = (tKwCb->u.dlCb->udxDlSap + spId);
238
239 #if (ERRCLASS & ERRCLS_INT_PAR)
240    KW_GET_AND_VALIDATE_UDXSAP(tKwCb,udxSap, EKW208, "KwUiDlUdxndReq");
241 #endif /* ERRCLASS & ERRCLS_INT_PAR */
242    udxSap->state = KW_SAP_CFG;
243    RETVALUE(ROK);
244 }
245
246 \f
247 /**
248  * @brief 
249  *    Handler for configuring RLC entities.
250  *
251  * @details
252  *    This function is used by RRC to configure(add/delete/modify)
253  *    one or more RLC entities. 
254  *        - CKW_CFG_ADD          => kwCfgAddRb
255  *        - CKW_CFG_MODIFY       => kwCfgReCfgRb
256  *        - CKW_CFG_DELETE       => kwCfgDelRb
257  *        - CKW_CFG_REESTABLISH  => kwCfgReEstRb
258  *        - CKW_CFG_DELETE_UE    => kwCfgDelUe
259  *
260  * @param[in] pst   -  Post structure  
261  * @param[in] spId  -  Serive Provider ID 
262  * @param[in] cfg   -  Configuration information for one or more RLC entities. 
263  *
264  * @return  S16
265  *    -# ROK 
266  *    -# RFAILED
267  */
268 #ifdef ANSI
269 PUBLIC S16 KwDlUdxCfgReq
270 (
271 Pst          *pst,
272 SpId         spId,
273 CkwCfgInfo   *cfg
274 )
275 #else
276 PUBLIC S16 KwDlUdxCfgReq(pst, spId, cfg)
277 Pst          *pst;
278 SpId         spId;
279 CkwCfgInfo   *cfg;
280 #endif
281 {
282    CkwCfgCfmInfo   *cfgCfm; 
283    U8              idx;    
284    KwCb            *tKwCb;
285    Pst             *pstUdxCfm;
286
287    TRC3(KwDlUdxCfgReq)
288
289 #if (ERRCLASS & ERRCLS_INT_PAR)
290    if (pst->dstInst >= KW_MAX_RLC_INSTANCES)
291    {
292       RETVALUE(RFAILED);
293    }
294 #endif
295
296    tKwCb = KW_GET_KWCB(pst->dstInst);
297
298    pstUdxCfm = &(tKwCb->u.dlCb->udxDlSap[spId].pst);
299    KWDBGP_BRIEF(tKwCb,"spId(%d)\n", spId);
300    /* Allocate memory and memset to 0 for cfmInfo */
301    KW_ALLOC_SHRABL_BUF_WC(pstUdxCfm->region,
302                           pstUdxCfm->pool,
303                           cfgCfm,
304                           sizeof(CkwCfgCfmInfo));
305
306 #if (ERRCLASS & ERRCLS_ADD_RES)
307    if (cfgCfm == NULLP)
308    {
309       RLOG0(L_FATAL,"Memory Allocation Failed.");
310       /* kw002.201 Freeing from proper region */
311       /* KW_PST_FREE(pst->region, pst->pool, cfg, sizeof(CkwCfgInfo)); */
312       RETVALUE(RFAILED);
313    }
314 #endif /* ERRCLASS & ERRCLS_ADD_RES */
315
316    /* For every entity configuration process by cfgType */
317    for (idx = 0; idx < cfg->numEnt; idx++)
318    {
319       CkwEntCfgCfmInfo   *entCfgCfm;
320       CkwEntCfgInfo      *entCfg;
321
322       entCfg  = (CkwEntCfgInfo *)&(cfg->entCfg[idx]);
323       entCfgCfm   = (CkwEntCfgCfmInfo *)&(cfgCfm->entCfgCfm[idx]);
324
325       switch (entCfg->cfgType)
326       {
327          case CKW_CFG_ADD:
328             {
329                if (entCfg->dir & KW_DIR_DL)
330                { 
331                   /* Add a new RB entity configuration */
332                   if (kwCfgAddDlRb(tKwCb,cfg->ueId, cfg->cellId,\
333                               entCfg, entCfgCfm) != ROK)
334                   {
335                      RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Addition Failed due to[%d]",
336                            entCfgCfm->status.reason);
337                   }
338                }
339                break;
340             }
341          case CKW_CFG_MODIFY:
342             {
343                if (entCfg->dir & KW_DIR_DL)
344                {
345                   /* Re-configure the existing RB entity configuration */
346                   if (kwCfgReCfgDlRb(tKwCb,cfg->ueId, cfg->cellId,\
347                            entCfg, entCfgCfm) != ROK)
348                   {
349                      RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"ReCfg Failed due to[%d]",
350                            entCfgCfm->status.reason);
351                   }
352                }
353                break;
354             }
355
356          case CKW_CFG_DELETE:
357             {
358                if (entCfg->dir & KW_DIR_DL)
359                {
360                   /* Delete the existing RB entity configuration */
361                   if (kwCfgDelDlRb(tKwCb,cfg->ueId, cfg->cellId,\
362                         entCfg, entCfgCfm) != ROK)
363                   {
364                      RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Deletion Failed due to[%d]",
365                            entCfgCfm->status.reason);
366                   } 
367                }
368                break;
369             }
370
371          case CKW_CFG_REESTABLISH:
372             {
373                if (entCfg->dir & KW_DIR_DL)
374                {
375                   /*if direction is both then, re-establishment end indication
376                    * should be sent only from the UL instance, only if DIR is
377                    * DL only then DL instance will send indication.*/
378                   Bool sndReEst = TRUE;
379                   if (entCfg->dir & KW_DIR_UL)
380                   {
381                      sndReEst = FALSE;
382                   }
383                   /* Re-establish the existing RB entity configuration */
384                   if (kwCfgReEstDlRb(tKwCb,cfg->ueId, cfg->cellId,
385                                      sndReEst,entCfg, entCfgCfm) != ROK)
386                   {
387                      RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Reest Failed due to[%d]",
388                            entCfgCfm->status.reason);
389                   }
390                }
391                break;
392             }
393
394          case CKW_CFG_DELETE_UE:
395             {
396                /* Delete all RB entity configuration under UE */
397                if (kwCfgDelDlUe(tKwCb,cfg->ueId, cfg->cellId,
398                                 entCfg, entCfgCfm) != ROK)
399                {
400                   RLOG_ARG1(L_ERROR,DBG_UEID,cfg->ueId,"deletion Failed due to[%d]",
401                            entCfgCfm->status.reason);
402                }
403                break;
404             }
405          case CKW_CFG_DELETE_CELL:
406             {
407                if (kwCfgDelDlCell(tKwCb,cfg->cellId,entCfg,entCfgCfm) 
408                                                                 != ROK )
409                {
410                   RLOG_ARG1(L_ERROR,DBG_CELLID,cfg->cellId,"deletion Failed due to[%d]",
411                            entCfgCfm->status.reason);
412                } 
413                break;
414             }
415
416          default:
417             {
418                KW_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,\
419                                    CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_CFG);
420                RLOG0(L_ERROR, "Invalid CfgType");
421             }
422       }
423    }
424
425    /* Assign number of entity configuraitons and suId */
426    cfgCfm->transId = cfg->transId;
427    cfgCfm->ueId = cfg->ueId;
428    cfgCfm->cellId = cfg->cellId;
429    cfgCfm->numEnt = cfg->numEnt;
430
431    /* kw002.201 Freeing from proper region */
432    /* KW_PST_FREE(pst->region, pst->pool, cfg, sizeof(CkwCfgInfo)); */
433    /* Send Configuration confirm primitive */
434    KwDlUdxCfgCfm(&(tKwCb->u.dlCb->udxDlSap[spId].pst),
435                  tKwCb->u.dlCb->udxDlSap[spId].suId, 
436                  cfgCfm);
437
438    RETVALUE(ROK);
439
440
441 /**
442  *@brief 
443  *   This primitive is used by RRC to change the UeId for the existing UE
444  *   context.
445  *
446  * @param pst     -  Pointer to the pst structure
447  * @param spId    -  The ID of the service provider SAP in the RLC layer 
448  * @param transId -  Transaction ID. This field uniquily identifies
449  *                   transaction between RRC and RLC
450  * @param ueInfo    -  Old UE Id Info for which the change request has come 
451  * @param newUeInfo -  New UE Id Info for existing UE context 
452  * 
453  * @return 
454  *    -# ROK
455  *    -# RFAILED
456  */
457 #ifdef ANSI
458 PUBLIC S16 KwDlUdxUeIdChgReq
459 (
460 Pst         *pst, 
461 SpId        spId, 
462 U32         transId, 
463 CkwUeInfo   *ueInfo,
464 CkwUeInfo   *newUeInfo
465 )
466 #else
467 PUBLIC S16 KwDlUdxUeIdChgReq(pst,spId,transId,ueInfo,newUeInfo)
468 Pst         *pst;
469 SpId        spId;
470 U32         transId;
471 CkwUeInfo   *ueInfo;
472 CkwUeInfo   *newUeInfo;
473 #endif
474 {
475    CmStatus       status;
476    KwCb           *tKwCb;
477
478    TRC3(KwDlUdxUeIdChgReq)
479
480 #if (ERRCLASS & ERRCLS_INT_PAR)
481    if (pst->dstInst >= KW_MAX_RLC_INSTANCES)
482    {
483       RETVALUE(RFAILED);
484    }
485 #endif
486
487    tKwCb = KW_GET_KWCB(pst->dstInst);
488 #ifndef ALIGN_64BIT
489    KWDBGP_BRIEF(tKwCb, "(spId(%d), transId(%ld))\n", 
490                 spId, transId);
491 #else
492    KWDBGP_BRIEF(tKwCb, "(spId(%d), transId(%d))\n", 
493                 spId, transId);
494 #endif
495
496    status.reason = CKW_CFG_REAS_NONE;
497    status.status = CKW_CFG_CFM_OK;
498    
499    if (kwCfgDlUeIdChng(tKwCb, ueInfo, newUeInfo, &status) != ROK)
500    {
501       RLOG_ARG1(L_ERROR,DBG_CELLID,newUeInfo->cellId,"Failure due to[%d]",
502              status.reason);
503    }
504    KwDlUdxUeIdChgCfm(&(tKwCb->u.dlCb->udxDlSap[spId].pst),
505                      tKwCb->u.dlCb->udxDlSap[spId].suId, 
506                      transId, 
507                      status);
508
509    RETVALUE(ROK);
510
511
512 /**
513 * @brief 
514 *    Request for status PDU from  ULM to DLM.
515 *
516 * @param[in]   pst   -  Post Structure
517 * @param[in]   spId  -  Service Provider Id
518 * @param[in]   rlcId -  Rlc Information Id
519 * @param[in]   pStaPdu - Status PDU 
520 *  
521 * @return   S16
522 *    -# ROK
523 *    -# RFAILED
524 **/
525 #ifdef ANSI
526 PUBLIC S16  KwDlUdxStaPduReq
527 (
528 Pst             *pst,
529 SpId            spId,
530 CmLteRlcId      *rlcId,
531 KwUdxDlStaPdu   *pStaPdu
532 )
533 #else
534 PUBLIC S16  KwDlUdxStaPduReq(pst, spId, rlcId, pStaPdu)
535 Pst             *pst;
536 SpId            spId;
537 CmLteRlcId      *rlcId;
538 KwUdxDlStaPdu   *pStaPdu;
539 #endif
540 {
541    KwDlRbCb   *rbCb;
542    KwCb       *tKwCb;
543
544    tKwCb =  KW_GET_KWCB (pst->dstInst);
545
546    kwDbmFetchDlRbCbByRbId(tKwCb, rlcId, &rbCb); /* Fetch DBM RbCb */
547    if (!rbCb)
548    {
549       RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
550             rlcId->cellId,rlcId->rbId);
551       KW_FREE_SHRABL_BUF(pst->region, 
552                          pst->pool, 
553                          pStaPdu, 
554                          sizeof(KwUdxDlStaPdu));
555       RETVALUE(RFAILED);
556    }
557
558    AMDL.cntrlBo = pStaPdu->controlBo;
559    /* If there already exists a STAUS PDU, free it and take the new one
560       into account */
561    if(AMDL.pStaPdu)
562    {
563       KW_FREE_SHRABL_BUF(pst->region, 
564                          pst->pool, 
565                          AMDL.pStaPdu, 
566                          sizeof(KwUdxDlStaPdu));
567    }
568    
569    AMDL.pStaPdu = pStaPdu;
570    kwAmmSendDStaRsp(tKwCb, rbCb, &AMDL);             
571
572    RETVALUE (ROK);
573 }
574
575 /**
576 * @brief 
577 *    It handles the status update recieved from ULM.
578 *
579 * @param[in]   pst   -  Post Structure
580 * @param[in]   spId  -  Service Provider Id
581 * @param[in]   rlcId -  Rlc Information Id
582 * @param[in]   pStaPdu - Status PDU 
583 *  
584 * @return   S16
585 *    -# ROK
586 *    -# RFAILED
587 **/
588 #ifdef ANSI
589 PUBLIC S16  KwDlUdxStaUpdReq
590 (
591 Pst*          pst,
592 SpId          spId,
593 CmLteRlcId    *rlcId,
594 KwUdxStaPdu   *pStaPdu
595 )
596 #else
597 PUBLIC S16 KwDlUdxStaUpdReq(pst, spId, rlcId,pStaPdu)
598 Pst*          pst;
599 SpId          spId;
600 CmLteRlcId    *rlcId;
601 KwUdxStaPdu   *pStaPdu;
602 #endif
603 {
604    KwCb          *tKwCb;
605    KwDlRbCb      *rbCb;
606
607    tKwCb = KW_GET_KWCB(pst->dstInst);
608
609    kwDbmFetchDlRbCbByRbId(tKwCb, rlcId, &rbCb);
610    if (!rbCb)
611    {
612       RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
613             rlcId->cellId,rlcId->rbId);
614       RETVALUE(RFAILED);
615    }
616
617    kwAmmDlHndlStatusPdu(tKwCb, rbCb, pStaPdu);
618
619    KW_FREE_SHRABL_BUF(pst->region,
620                       pst->pool, 
621                       pStaPdu, 
622                       sizeof(KwUdxStaPdu));
623
624    RETVALUE(ROK);
625 }
626
627 #ifdef LTE_L2_MEAS
628 /**
629 */
630 #ifdef ANSI
631 PUBLIC S16 KwDlUdxL2MeasReq 
632 (
633 Pst            *pst, 
634 KwL2MeasReqEvt *measReqEvt 
635 )
636 #else
637 PUBLIC S16 KwDlUdxL2MeasReq (pst, measReqEvt)
638 Pst            *pst; 
639 KwL2MeasReqEvt *measReqEvt;
640 #endif
641 {
642    U32            cntr;
643    U8             measType;
644    VOLATILE U32     startTime = 0;
645    KwCb     *tKwCb;
646
647    TRC3(KwDlUdxL2MeasReq);
648
649    /*starting Task*/
650    SStartTask(&startTime, PID_RLC_MEAS_START);
651
652    tKwCb =  KW_GET_KWCB(pst->dstInst);
653
654    /* Initialize measCfmEvt */
655
656   /* validate the received measReqEvt */
657  /*LTE_L2_MEAS_PHASE2*/
658
659    measType = measReqEvt->measReq.measType;
660
661    if(measType & LKW_L2MEAS_DL_IP) 
662    {
663       /* if measurement is for DL IP enable for all QCI */
664       for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
665       {
666          tKwCb->u.dlCb->kwL2Cb.measOn[cntr] |= LKW_L2MEAS_DL_IP;
667       }
668    }
669    else
670    {
671       /* for nonIpThroughput meas, enable only for the sent QCIs */
672       U32 i;
673       for(i = 0; i < LKW_MAX_QCI; i++)
674       {
675          tKwCb->u.dlCb->kwL2Cb.measOn[i] |= measType;
676       }
677    }
678
679    /* We need to copy the transId for sending back confirms later */
680    for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
681    {
682       KwL2MeasEvtCb* measEvtCb = &(tKwCb->u.dlCb->kwL2Cb.kwL2EvtCb[cntr]);
683       if(measEvtCb->measCb.measType & measType)
684       {
685          measEvtCb->transId= measReqEvt->transId;
686       }
687    }
688
689    /*stopping Task*/
690    SStopTask(startTime, PID_RLC_MEAS_START);
691    RETVALUE(ROK);
692 } /* KwDlUdxMeasReq */
693
694 /**
695 @brief 
696 This function processes L2 Measurement stop request received from the layer manager.
697 After receving this request, RLC stops L2 Measurement
698  *  @param[in] pst      post structure
699  *  @param[in] measType meas Type 
700  *  @return S16
701  *      -# Success : ROK
702  *      -# Failure : RFAILED
703 */
704
705 #ifdef ANSI
706 PUBLIC S16 KwDlUdxL2MeasStopReq
707 (
708 Pst            *pst,
709 U8             measType
710 )
711 #else
712 PUBLIC S16 KwDlUdxL2MeasStopReq (pst, measType)
713 Pst            *pst;
714 U8             measType;
715 #endif
716 {
717   /* S16 ret = ROK;*/
718    KwL2MeasEvtCb *measEvtCb = NULLP;
719    U16            cntr;
720    U8             status = ROK;
721 /*   KwL2MeasCfmEvt          measCfmEvt;  */
722    VOLATILE U32     startTime = 0;
723    KwCb     *tKwCb=NULLP;
724    TRC3(KwDlUdxMeasStopReq);
725    
726    /*starting Task*/
727    SStartTask(&startTime, PID_RLC_MEAS_STOP);
728
729    tKwCb =  KW_GET_KWCB(pst->dstInst);
730 /*   cmMemset((U8*)&measCfmEvt, 0, sizeof(KwL2MeasCfmEvt)); */
731    /* reset the counters for the measurement type passed */
732    for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
733    {
734       measEvtCb = &(tKwCb->u.dlCb->kwL2Cb.kwL2EvtCb[cntr]);
735       if(measEvtCb->measCb.measType & measType)
736       {
737          kwUtlResetDlL2MeasInKwRb(tKwCb, &measEvtCb->measCb, measType);
738
739       }
740    }
741
742    /* switch off the measurements for the type passed */
743    for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
744    {
745       tKwCb->u.dlCb->kwL2Cb.measOn[cntr] &= ~measType;
746    }
747    
748    status = LCM_PRIM_OK;
749    /* Stop confirm is removed as UL thread is already sending it */
750    
751    /*stopping Task*/
752    SStopTask(startTime, PID_RLC_MEAS_STOP);
753
754    RETVALUE(ROK);
755 }
756 /**
757 @brief 
758 This function processes L2 Measurement Send request received from the layer manager.
759 After receving this request, RLC sends L2 Measurement
760  *  @param[in] pst      post structure
761  *  @param[in] measType meas Type 
762  *  @return S16
763  *      -# Success : ROK
764  *      -# Failure : RFAILED
765 */
766
767 #ifdef ANSI
768 PUBLIC S16 KwDlUdxL2MeasSendReq
769 (
770 Pst            *pst,
771 U8             measType
772 )
773 #else
774 PUBLIC S16 KwDlUdxL2MeasSendReq (pst, measType)
775 Pst            *pst;
776 U8             measType;
777 #endif
778 {
779    KwL2MeasEvtCb *measEvtCb;
780    U16            cntr;
781    
782    VOLATILE U32     startTime = 0;
783    KwCb     *tKwCb;
784    TRC3(KwDlUdxMeasSendReq);
785
786    tKwCb =  KW_GET_KWCB(pst->dstInst);
787    for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
788    {
789       measEvtCb = &(tKwCb->u.dlCb->kwL2Cb.kwL2EvtCb[cntr]);
790       if(measEvtCb->measCb.measType & measType)
791       {
792          /*starting Task*/
793          SStartTask(&startTime, PID_RLC_MEAS_REPORT);
794
795          kwUtlSndDlL2MeasCfm(tKwCb, measEvtCb);
796
797          /*stopping Task*/
798          SStopTask(startTime, PID_RLC_MEAS_REPORT);
799       }
800    }
801
802    RETVALUE(ROK);
803 }
804 #endif /* LTE_L2_MEAS */
805
806 #ifdef __cplusplus
807 }
808 #endif /* __cplusplus */
809
810 \f
811 /**********************************************************************
812          End of file
813 **********************************************************************/