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