F1-U Data path changes
[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    S16             ret = ROK;
285    KwCb            *tKwCb;
286    Pst             *pstUdxCfm;
287
288    TRC3(KwDlUdxCfgReq)
289
290 #if (ERRCLASS & ERRCLS_INT_PAR)
291    if (pst->dstInst >= KW_MAX_RLC_INSTANCES)
292    {
293       RETVALUE(RFAILED);
294    }
295 #endif
296
297    tKwCb = KW_GET_KWCB(pst->dstInst);
298
299    pstUdxCfm = &(tKwCb->u.dlCb->udxDlSap[spId].pst);
300    KWDBGP_BRIEF(tKwCb,"spId(%d)\n", spId);
301    /* Allocate memory and memset to 0 for cfmInfo */
302    KW_ALLOC_SHRABL_BUF_WC(pstUdxCfm->region,
303                           pstUdxCfm->pool,
304                           cfgCfm,
305                           sizeof(CkwCfgCfmInfo));
306
307 #if (ERRCLASS & ERRCLS_ADD_RES)
308    if (cfgCfm == NULLP)
309    {
310       RLOG0(L_FATAL,"Memory Allocation Failed.");
311       /* kw002.201 Freeing from proper region */
312       /* KW_PST_FREE(pst->region, pst->pool, cfg, sizeof(CkwCfgInfo)); */
313       RETVALUE(RFAILED);
314    }
315 #endif /* ERRCLASS & ERRCLS_ADD_RES */
316
317    /* For every entity configuration process by cfgType */
318    for (idx = 0; idx < cfg->numEnt; idx++)
319    {
320       CkwEntCfgCfmInfo   *entCfgCfm;
321       CkwEntCfgInfo      *entCfg;
322
323       entCfg  = (CkwEntCfgInfo *)&(cfg->entCfg[idx]);
324       entCfgCfm   = (CkwEntCfgCfmInfo *)&(cfgCfm->entCfgCfm[idx]);
325
326       switch (entCfg->cfgType)
327       {
328          case CKW_CFG_ADD:
329             {
330                if (entCfg->dir & KW_DIR_DL)
331                { 
332                   /* Add a new RB entity configuration */
333                   if (kwCfgAddDlRb(tKwCb,cfg->ueId, cfg->cellId,\
334                               entCfg, entCfgCfm) != ROK)
335                   {
336                      RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Addition Failed due to[%d]",
337                            entCfgCfm->status.reason);
338                   }
339                }
340                break;
341             }
342          case CKW_CFG_MODIFY:
343             {
344                if (entCfg->dir & KW_DIR_DL)
345                {
346                   /* Re-configure the existing RB entity configuration */
347                   if (kwCfgReCfgDlRb(tKwCb,cfg->ueId, cfg->cellId,\
348                            entCfg, entCfgCfm) != ROK)
349                   {
350                      RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"ReCfg Failed due to[%d]",
351                            entCfgCfm->status.reason);
352                   }
353                }
354                break;
355             }
356
357          case CKW_CFG_DELETE:
358             {
359                if (entCfg->dir & KW_DIR_DL)
360                {
361                   /* Delete the existing RB entity configuration */
362                   if (kwCfgDelDlRb(tKwCb,cfg->ueId, cfg->cellId,\
363                         entCfg, entCfgCfm) != ROK)
364                   {
365                      RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Deletion Failed due to[%d]",
366                            entCfgCfm->status.reason);
367                   } 
368                }
369                break;
370             }
371
372          case CKW_CFG_REESTABLISH:
373             {
374                if (entCfg->dir & KW_DIR_DL)
375                {
376                   /*if direction is both then, re-establishment end indication
377                    * should be sent only from the UL instance, only if DIR is
378                    * DL only then DL instance will send indication.*/
379                   Bool sndReEst = TRUE;
380                   if (entCfg->dir & KW_DIR_UL)
381                   {
382                      sndReEst = FALSE;
383                   }
384                   /* Re-establish the existing RB entity configuration */
385                   if (kwCfgReEstDlRb(tKwCb,cfg->ueId, cfg->cellId,
386                                      sndReEst,entCfg, entCfgCfm) != ROK)
387                   {
388                      RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Reest Failed due to[%d]",
389                            entCfgCfm->status.reason);
390                   }
391                }
392                break;
393             }
394
395          case CKW_CFG_DELETE_UE:
396             {
397                /* Delete all RB entity configuration under UE */
398                if (kwCfgDelDlUe(tKwCb,cfg->ueId, cfg->cellId,
399                                 entCfg, entCfgCfm) != ROK)
400                {
401                   RLOG_ARG1(L_ERROR,DBG_UEID,cfg->ueId,"deletion Failed due to[%d]",
402                            entCfgCfm->status.reason);
403                }
404                break;
405             }
406          case CKW_CFG_DELETE_CELL:
407             {
408                if (kwCfgDelDlCell(tKwCb,cfg->cellId,entCfg,entCfgCfm) 
409                                                                 != ROK )
410                {
411                   RLOG_ARG1(L_ERROR,DBG_CELLID,cfg->cellId,"deletion Failed due to[%d]",
412                            entCfgCfm->status.reason);
413                } 
414                break;
415             }
416
417          default:
418             {
419                KW_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,\
420                                    CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_CFG);
421                RLOG0(L_ERROR, "Invalid CfgType");
422             }
423       }
424    }
425
426    /* Assign number of entity configuraitons and suId */
427    cfgCfm->transId = cfg->transId;
428    cfgCfm->ueId = cfg->ueId;
429    cfgCfm->cellId = cfg->cellId;
430    cfgCfm->numEnt = cfg->numEnt;
431
432    /* kw002.201 Freeing from proper region */
433    /* KW_PST_FREE(pst->region, pst->pool, cfg, sizeof(CkwCfgInfo)); */
434    /* Send Configuration confirm primitive */
435    KwDlUdxCfgCfm(&(tKwCb->u.dlCb->udxDlSap[spId].pst),
436                  tKwCb->u.dlCb->udxDlSap[spId].suId, 
437                  cfgCfm);
438
439    RETVALUE(ROK);
440
441
442 /**
443  *@brief 
444  *   This primitive is used by RRC to change the UeId for the existing UE
445  *   context.
446  *
447  * @param pst     -  Pointer to the pst structure
448  * @param spId    -  The ID of the service provider SAP in the RLC layer 
449  * @param transId -  Transaction ID. This field uniquily identifies
450  *                   transaction between RRC and RLC
451  * @param ueInfo    -  Old UE Id Info for which the change request has come 
452  * @param newUeInfo -  New UE Id Info for existing UE context 
453  * 
454  * @return 
455  *    -# ROK
456  *    -# RFAILED
457  */
458 #ifdef ANSI
459 PUBLIC S16 KwDlUdxUeIdChgReq
460 (
461 Pst         *pst, 
462 SpId        spId, 
463 U32         transId, 
464 CkwUeInfo   *ueInfo,
465 CkwUeInfo   *newUeInfo
466 )
467 #else
468 PUBLIC S16 KwDlUdxUeIdChgReq(pst,spId,transId,ueInfo,newUeInfo)
469 Pst         *pst;
470 SpId        spId;
471 U32         transId;
472 CkwUeInfo   *ueInfo;
473 CkwUeInfo   *newUeInfo;
474 #endif
475 {
476    CmStatus       status;
477    KwCb           *tKwCb;
478
479    TRC3(KwDlUdxUeIdChgReq)
480
481 #if (ERRCLASS & ERRCLS_INT_PAR)
482    if (pst->dstInst >= KW_MAX_RLC_INSTANCES)
483    {
484       RETVALUE(RFAILED);
485    }
486 #endif
487
488    tKwCb = KW_GET_KWCB(pst->dstInst);
489 #ifndef ALIGN_64BIT
490    KWDBGP_BRIEF(tKwCb, "(spId(%d), transId(%ld))\n", 
491                 spId, transId);
492 #else
493    KWDBGP_BRIEF(tKwCb, "(spId(%d), transId(%d))\n", 
494                 spId, transId);
495 #endif
496
497    status.reason = CKW_CFG_REAS_NONE;
498    status.status = CKW_CFG_CFM_OK;
499    
500    if (kwCfgDlUeIdChng(tKwCb, ueInfo, newUeInfo, &status) != ROK)
501    {
502       RLOG_ARG1(L_ERROR,DBG_CELLID,newUeInfo->cellId,"Failure due to[%d]",
503              status.reason);
504    }
505    KwDlUdxUeIdChgCfm(&(tKwCb->u.dlCb->udxDlSap[spId].pst),
506                      tKwCb->u.dlCb->udxDlSap[spId].suId, 
507                      transId, 
508                      status);
509
510    RETVALUE(ROK);
511
512
513 /**
514 * @brief 
515 *    Request for status PDU from  ULM to DLM.
516 *
517 * @param[in]   pst   -  Post Structure
518 * @param[in]   spId  -  Service Provider Id
519 * @param[in]   rlcId -  Rlc Information Id
520 * @param[in]   pStaPdu - Status PDU 
521 *  
522 * @return   S16
523 *    -# ROK
524 *    -# RFAILED
525 **/
526 #ifdef ANSI
527 PUBLIC S16  KwDlUdxStaPduReq
528 (
529 Pst             *pst,
530 SpId            spId,
531 CmLteRlcId      *rlcId,
532 KwUdxDlStaPdu   *pStaPdu
533 )
534 #else
535 PUBLIC S16  KwDlUdxStaPduReq(pst, spId, rlcId, pStaPdu)
536 Pst             *pst;
537 SpId            spId;
538 CmLteRlcId      *rlcId;
539 KwUdxDlStaPdu   *pStaPdu;
540 #endif
541 {
542    KwDlRbCb   *rbCb;
543    KwCb       *tKwCb;
544
545    tKwCb =  KW_GET_KWCB (pst->dstInst);
546
547    kwDbmFetchDlRbCbByRbId(tKwCb, rlcId, &rbCb); /* Fetch DBM RbCb */
548    if (!rbCb)
549    {
550       RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
551             rlcId->cellId,rlcId->rbId);
552       KW_FREE_SHRABL_BUF(pst->region, 
553                          pst->pool, 
554                          pStaPdu, 
555                          sizeof(KwUdxDlStaPdu));
556       RETVALUE(RFAILED);
557    }
558
559    AMDL.cntrlBo = pStaPdu->controlBo;
560    /* If there already exists a STAUS PDU, free it and take the new one
561       into account */
562    if(AMDL.pStaPdu)
563    {
564       KW_FREE_SHRABL_BUF(pst->region, 
565                          pst->pool, 
566                          AMDL.pStaPdu, 
567                          sizeof(KwUdxDlStaPdu));
568    }
569    
570    AMDL.pStaPdu = pStaPdu;
571    kwAmmSendDStaRsp(tKwCb, rbCb, &AMDL);             
572
573    RETVALUE (ROK);
574 }
575
576 /**
577 * @brief 
578 *    It handles the status update recieved from ULM.
579 *
580 * @param[in]   pst   -  Post Structure
581 * @param[in]   spId  -  Service Provider Id
582 * @param[in]   rlcId -  Rlc Information Id
583 * @param[in]   pStaPdu - Status PDU 
584 *  
585 * @return   S16
586 *    -# ROK
587 *    -# RFAILED
588 **/
589 #ifdef ANSI
590 PUBLIC S16  KwDlUdxStaUpdReq
591 (
592 Pst*          pst,
593 SpId          spId,
594 CmLteRlcId    *rlcId,
595 KwUdxStaPdu   *pStaPdu
596 )
597 #else
598 PUBLIC S16 KwDlUdxStaUpdReq(pst, spId, rlcId,pStaPdu)
599 Pst*          pst;
600 SpId          spId;
601 CmLteRlcId    *rlcId;
602 KwUdxStaPdu   *pStaPdu;
603 #endif
604 {
605    KwCb          *tKwCb;
606    KwDlRbCb      *rbCb;
607
608    tKwCb = KW_GET_KWCB(pst->dstInst);
609
610    kwDbmFetchDlRbCbByRbId(tKwCb, rlcId, &rbCb);
611    if (!rbCb)
612    {
613       RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
614             rlcId->cellId,rlcId->rbId);
615       RETVALUE(RFAILED);
616    }
617
618    kwAmmDlHndlStatusPdu(tKwCb, rbCb, pStaPdu);
619
620    KW_FREE_SHRABL_BUF(pst->region,
621                       pst->pool, 
622                       pStaPdu, 
623                       sizeof(KwUdxStaPdu));
624
625    RETVALUE(ROK);
626 }
627
628 #ifdef LTE_L2_MEAS
629 /**
630 */
631 #ifdef ANSI
632 PUBLIC S16 KwDlUdxL2MeasReq 
633 (
634 Pst            *pst, 
635 KwL2MeasReqEvt *measReqEvt 
636 )
637 #else
638 PUBLIC S16 KwDlUdxL2MeasReq (pst, measReqEvt)
639 Pst            *pst; 
640 KwL2MeasReqEvt *measReqEvt;
641 #endif
642 {
643    U32            cntr;
644    U8             measType;
645    VOLATILE U32     startTime = 0;
646    KwCb     *tKwCb;
647
648    TRC3(KwDlUdxL2MeasReq);
649
650    /*starting Task*/
651    SStartTask(&startTime, PID_RLC_MEAS_START);
652
653    tKwCb =  KW_GET_KWCB(pst->dstInst);
654
655    /* Initialize measCfmEvt */
656
657   /* validate the received measReqEvt */
658  /*LTE_L2_MEAS_PHASE2*/
659
660    measType = measReqEvt->measReq.measType;
661
662    if(measType & LKW_L2MEAS_DL_IP) 
663    {
664       /* if measurement is for DL IP enable for all QCI */
665       for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
666       {
667          tKwCb->u.dlCb->kwL2Cb.measOn[cntr] |= LKW_L2MEAS_DL_IP;
668       }
669    }
670    else
671    {
672       /* for nonIpThroughput meas, enable only for the sent QCIs */
673       U32 i;
674       for(i = 0; i < LKW_MAX_QCI; i++)
675       {
676          tKwCb->u.dlCb->kwL2Cb.measOn[i] |= measType;
677       }
678    }
679
680    /* We need to copy the transId for sending back confirms later */
681    for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
682    {
683       KwL2MeasEvtCb* measEvtCb = &(tKwCb->u.dlCb->kwL2Cb.kwL2EvtCb[cntr]);
684       if(measEvtCb->measCb.measType & measType)
685       {
686          measEvtCb->transId= measReqEvt->transId;
687       }
688    }
689
690    /*stopping Task*/
691    SStopTask(startTime, PID_RLC_MEAS_START);
692    RETVALUE(ROK);
693 } /* KwDlUdxMeasReq */
694
695 /**
696 @brief 
697 This function processes L2 Measurement stop request received from the layer manager.
698 After receving this request, RLC stops L2 Measurement
699  *  @param[in] pst      post structure
700  *  @param[in] measType meas Type 
701  *  @return S16
702  *      -# Success : ROK
703  *      -# Failure : RFAILED
704 */
705
706 #ifdef ANSI
707 PUBLIC S16 KwDlUdxL2MeasStopReq
708 (
709 Pst            *pst,
710 U8             measType
711 )
712 #else
713 PUBLIC S16 KwDlUdxL2MeasStopReq (pst, measType)
714 Pst            *pst;
715 U8             measType;
716 #endif
717 {
718   /* S16 ret = ROK;*/
719    KwL2MeasEvtCb *measEvtCb = NULLP;
720    U16            cntr;
721    U8             status = ROK;
722 /*   KwL2MeasCfmEvt          measCfmEvt;  */
723    VOLATILE U32     startTime = 0;
724    KwCb     *tKwCb=NULLP;
725    TRC3(KwDlUdxMeasStopReq);
726    
727    /*starting Task*/
728    SStartTask(&startTime, PID_RLC_MEAS_STOP);
729
730    tKwCb =  KW_GET_KWCB(pst->dstInst);
731 /*   cmMemset((U8*)&measCfmEvt, 0, sizeof(KwL2MeasCfmEvt)); */
732    /* reset the counters for the measurement type passed */
733    for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
734    {
735       measEvtCb = &(tKwCb->u.dlCb->kwL2Cb.kwL2EvtCb[cntr]);
736       if(measEvtCb->measCb.measType & measType)
737       {
738          kwUtlResetDlL2MeasInKwRb(tKwCb, &measEvtCb->measCb, measType);
739
740       }
741    }
742
743    /* switch off the measurements for the type passed */
744    for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
745    {
746       tKwCb->u.dlCb->kwL2Cb.measOn[cntr] &= ~measType;
747    }
748    
749    status = LCM_PRIM_OK;
750    /* Stop confirm is removed as UL thread is already sending it */
751    
752    /*stopping Task*/
753    SStopTask(startTime, PID_RLC_MEAS_STOP);
754
755    RETVALUE(ROK);
756 }
757 /**
758 @brief 
759 This function processes L2 Measurement Send request received from the layer manager.
760 After receving this request, RLC sends L2 Measurement
761  *  @param[in] pst      post structure
762  *  @param[in] measType meas Type 
763  *  @return S16
764  *      -# Success : ROK
765  *      -# Failure : RFAILED
766 */
767
768 #ifdef ANSI
769 PUBLIC S16 KwDlUdxL2MeasSendReq
770 (
771 Pst            *pst,
772 U8             measType
773 )
774 #else
775 PUBLIC S16 KwDlUdxL2MeasSendReq (pst, measType)
776 Pst            *pst;
777 U8             measType;
778 #endif
779 {
780    KwL2MeasEvtCb *measEvtCb;
781    U16            cntr;
782    
783    VOLATILE U32     startTime = 0;
784    KwCb     *tKwCb;
785    TRC3(KwDlUdxMeasSendReq);
786
787    tKwCb =  KW_GET_KWCB(pst->dstInst);
788    for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
789    {
790       measEvtCb = &(tKwCb->u.dlCb->kwL2Cb.kwL2EvtCb[cntr]);
791       if(measEvtCb->measCb.measType & measType)
792       {
793          /*starting Task*/
794          SStartTask(&startTime, PID_RLC_MEAS_REPORT);
795
796          kwUtlSndDlL2MeasCfm(tKwCb, measEvtCb);
797
798          /*stopping Task*/
799          SStopTask(startTime, PID_RLC_MEAS_REPORT);
800       }
801    }
802
803    RETVALUE(ROK);
804 }
805 #endif /* LTE_L2_MEAS */
806
807 #ifdef __cplusplus
808 }
809 #endif /* __cplusplus */
810
811 \f
812 /**********************************************************************
813          End of file
814 **********************************************************************/