Committing in PDCP code
[o-du/l2.git] / src / 5gnrpdcp / pj_udx_ul.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-PDCP Layer - Upper Interface
22     
23         Type:    C file
24   
25         Desc:    C source code for the upper interface of LTE-PDCP
26  
27         File:    pj_udx_ul.c
28   
29 *********************************************************************21*/
30 static const char* RLOG_MODULE_NAME="PDCP";
31 static int RLOG_MODULE_ID=1024;
32 static int RLOG_FILE_ID=226;
33 /** @file pj_udx_ul.c
34 @brief PDCP Upper Interface
35 */
36
37 \f
38 /* header (.h) include files */
39 #include "envopt.h"        /* environment options */
40 #include "envdep.h"        /* environment dependent */
41 #include "envind.h"        /* environment independent */
42
43 #include "gen.h"           /* general */
44 #include "ssi.h"           /* system services */
45 #include "cm5.h"           /* common timer defines */
46 #include "cm_tkns.h"       /* common tokens defines */
47 #include "cm_mblk.h"       /* common memory allocation library defines */
48 #include "cm_llist.h"      /* common link list  defines  */
49 #include "cm_hash.h"       /* common hash list  defines */
50 #include "cm_lte.h"        /* common LTE defines */
51 #include "cpj.h"           /* UDX defines */
52 #include "pju.h"           /* PJU defines */
53 #include "lpj.h"           /* LPJ defines */
54
55 #include "pj_err.h"
56 #include "pj_env.h"        /* RLC environment options */
57 #include "pj.h"
58 #include "pj_ul.h"
59 #include "pj_udx.h"
60
61 /* extern (.x) include files */
62 #include "gen.x"           /* general */
63 #include "ssi.x"           /* system services */
64
65 #include "cm5.x"           /* common timer library */
66 #include "cm_tkns.x"       /* common tokens */
67 #include "cm_mblk.x"       /* common memory allocation */
68 #include "cm_llist.x"      /* common link list */
69 #include "cm_hash.x"       /* common hash list */
70 #include "cm_lte.x"        /* common LTE includes */
71 #include "cm_lib.x"        /* common memory allocation library */
72 #include "cpj.x"           /* UDX defines */
73 #include "pju.x"           /* PJU defines */
74 #include "lpj.x"           /* LPJ defines */
75 #include "pj.x"
76 #include "pj_udx.h"
77 #include "pj_udx.x"
78 #include "pj_ul.x"
79
80 PRIVATE S16 pjHdlCpjUlCfgReq ARGS((PjCb  *gCb,PjCfgInfo *cfgInfo,
81               UdxCfgCfmInfo *cfmInfo, CpjCfgCfmInfo *cfgCfm, Bool *sndCfgCfm));
82
83
84
85 /**
86   * @brief
87   * UDX APIs
88   */
89 /**
90  *
91  * @brief 
92  *
93  *        Handler for bind confirmation from DL.
94  *
95  * @b Description:
96  *
97  *        This function handles the bind confirmation received
98  *        from MAC. 
99  *
100  *  @param[in] pst     Post structure  
101  *  @param[in] suId    Service User ID
102  */
103
104
105 \f  
106 /****************************************************************************
107  *                         UDX Interface Mt functions
108  ***************************************************************************/\f
109 #ifdef ANSI
110 PUBLIC S16 PjUlUdxBndCfm
111 (
112 Pst * pst,
113 SuId suId,
114 U8 status
115 )
116 #else
117 PUBLIC S16 PjUlUdxBndCfm(pst, suId, status)
118 Pst * pst;
119 SuId suId;
120 U8 status;
121 #endif
122 {
123    U16             event;              /* Event */
124    U16             cause;              /* Cause */
125    PjUdxUlSapCb      *udxSap;            /* RGU SAP Control Block */
126    PjCb            *tPjCb;
127
128    TRC3(PjUlUdxBndCfm)
129
130 #if (ERRCLASS & ERRCLS_INT_PAR)
131    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
132    {
133       RETVALUE (RFAILED);
134    }
135 #endif
136    tPjCb = PJ_GET_PJCB(pst->dstInst);
137
138 #ifdef DEBUGP
139    RLOG2(L_DEBUG, "PjUlUdxBndCfm(post, suId(%d), status(%d)", suId, status);
140 #endif
141
142 #if (ERRCLASS & ERRCLS_INT_PAR)
143    if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
144    {
145       /* INNC: ERROR CLASS */
146       RLOG0(L_FATAL, "General configuration not done");
147       PJ_SEND_SAPID_ALARM(tPjCb,suId, 
148                           LPJ_EVENT_LI_BND_CFM, LCM_CAUSE_INV_STATE);
149
150       RETVALUE(RFAILED);
151    }
152
153    if (suId < 0)
154    {
155       /* INNC: ERROR CLASS */
156       RLOG0(L_ERROR, "Invalid suId");
157       PJ_SEND_SAPID_ALARM(tPjCb,suId, 
158                            LPJ_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
159
160       RETVALUE(RFAILED);
161    }
162 #endif /* ERRCLASS & ERRCLS_INT_PAR */
163
164    udxSap = tPjCb->u.ulCb->udxUlSap + suId;
165
166 #ifdef DEBUGP
167    RLOG1(L_DEBUG, "PjLiRguBndCfm: For RGU SAP state=%d",
168        udxSap->state);
169 #endif
170
171    /* Check rguSap state */
172    switch (udxSap->state)
173    {
174       case PJ_SAP_BINDING:
175       {
176          pjStopTmr (tPjCb,(PTR)udxSap, PJ_EVT_WAIT_UDX_BNDCFM);
177
178          udxSap->retryCnt = 0;
179           
180          if (status == CM_BND_OK)
181          {
182             udxSap->state = PJ_SAP_BND;
183             event = LCM_EVENT_BND_OK;
184             cause = LPJ_CAUSE_SAP_BNDENB;
185          }
186          else
187          {
188             udxSap->state = PJ_SAP_CFG;
189             event = LCM_EVENT_BND_FAIL;
190             cause = LPJ_CAUSE_UNKNOWN;
191          }
192       }
193       break;
194
195      default:
196         event = LPJ_EVENT_RGU_BND_CFM;
197         cause = LCM_CAUSE_INV_STATE;
198         break;
199    }
200
201    /* Send an alarm with proper event and cause */
202    /*PJ_SEND_SAPID_ALARM(tPjCb,suId, event, cause);*/
203 #ifdef LTE_L2_MEAS
204    pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, event, cause, suId, 0,0); 
205 #else
206    pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, event, cause, suId, 0); 
207 #endif
208
209    RETVALUE(ROK);
210 }
211
212 #ifdef ANSI
213 PUBLIC S16 PjUlUdxCfgCfm
214 (
215 Pst * pst,
216 SuId suId,
217 UdxCfgCfmInfo * cfmInfo
218 )
219 #else
220 PUBLIC S16 PjUlUdxCfgCfm(pst, suId, cfmInfo)
221 Pst * pst;
222 SuId suId;
223 UdxCfgCfmInfo * cfmInfo;
224 #endif
225 {
226    S16              ret;
227    PjCpjSapCb     *cpjSap;
228    PjCb            *tPjCb;
229    CpjCfgCfmInfo   *cfgCfm;
230    Bool            sndCfgCfm;
231    PjCfgInfo       *cfgInfo;
232
233    TRC3(PjUlUdxCfgCfm)
234
235 #if (ERRCLASS & ERRCLS_INT_PAR)
236    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
237    {
238       RETVALUE (RFAILED);
239    }
240 #endif
241    tPjCb = PJ_GET_PJCB(pst->dstInst);
242
243 #ifdef DEBUGP
244    RLOG1(L_DEBUG, "PjUlUdxBndCfm(post, suId(%d), )", suId);
245 #endif
246
247 #if (ERRCLASS & ERRCLS_INT_PAR)
248    if (suId < 0)
249    {
250       /* INNC: ERROR CLASS */
251       RLOG0(L_ERROR, "Invalid suId");
252       PJ_SEND_SAPID_ALARM(tPjCb,suId, 
253                            LPJ_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
254
255       RETVALUE(RFAILED);
256    }
257 #endif /* ERRCLASS & ERRCLS_INT_PAR */
258
259    ret = pjDbmFindUlTransIdLst(tPjCb,cfmInfo->transId, &cfgInfo);
260    if (ret != ROK)
261    {
262       RLOG0(L_ERROR, "Invalid transId");
263       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cfmInfo, sizeof (UdxCfgCfmInfo));
264       RETVALUE (RFAILED);
265    }
266    /* Allocate memory and memset to 0 for cfmInfo */
267    cpjSap = &(tPjCb->u.ulCb->cpjSap);
268    if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfgCfm, 
269       sizeof (CpjCfgCfmInfo)) != ROK)
270    {
271       RLOG0(L_FATAL, "Memory Allocation failed.");
272       /* pj002.201 Freeing from proper region */
273       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cfmInfo, sizeof (UdxCfgCfmInfo));
274       PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->cfgInfo, sizeof(CpjCfgReqInfo));
275       PJ_FREE(tPjCb,cfgInfo,sizeof(PjCfgInfo));
276       RETVALUE(RFAILED);
277    }
278
279    sndCfgCfm = TRUE;
280    ret = pjHdlCpjUlCfgReq(tPjCb,cfgInfo, cfmInfo, cfgCfm, &sndCfgCfm);
281 /* AGHOSH */
282    /* Free the cfg confirm allocated from DL, this should actually
283       be a sharable buffer and not a static buffer */
284    PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cfmInfo, sizeof (UdxCfgCfmInfo));
285    PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->cfgInfo, sizeof(CpjCfgReqInfo));
286    PJ_FREE(tPjCb,cfgInfo,sizeof(PjCfgInfo));
287 /* AGHOSH */
288    
289    if (sndCfgCfm)
290    {
291        cpjSap = &(tPjCb->u.ulCb->cpjSap);
292
293        PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm);
294    }
295
296    
297    RETVALUE(ROK);
298 }
299
300 #ifdef ANSI
301 PUBLIC S16 PjUlUdxReEstCfm
302 (
303 Pst               *pst,
304 SuId              suId,
305 UdxReEstCfmInfo   *reEstCfm
306 )
307 #else
308 PUBLIC S16 PjUlUdxReEstCfm(pst, suId, reEstCfm)
309 Pst               *pst;
310 SuId              suId;
311 UdxReEstCfmInfo   *reEstCfm;
312 #endif
313 {
314    S16              ret;
315    PjCpjSapCb      *cpjSap;
316    PjCb            *tPjCb;
317    PjCfgInfo       *cfgInfo;
318    CpjReEstCfmInfo *cpjReEstCfm;
319     
320    TRC3(PjUlUdxReEstCfm)
321
322 #if (ERRCLASS & ERRCLS_INT_PAR)
323    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
324    {
325       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo));
326
327       RETVALUE (RFAILED);
328    }
329 #endif
330    tPjCb = PJ_GET_PJCB(pst->dstInst);
331
332 #ifdef DEBUGP
333    RLOG1(L_DEBUG, "PjUlUdxReEstCfm(post, suId(%d), ", suId);
334 #endif
335
336 #if (ERRCLASS & ERRCLS_INT_PAR)
337    if (suId < 0)
338    {
339       /* INNC: ERROR CLASS */
340       RLOG0(L_ERROR, "Invalid suId");
341       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo));
342       RETVALUE(RFAILED);
343    }
344 #endif /* ERRCLASS & ERRCLS_INT_PAR */
345
346    ret = pjDbmFindUlTransIdLst(tPjCb, reEstCfm->transId, &cfgInfo);
347    if (ret != ROK)
348    {
349       RLOG0(L_ERROR, "Invalid transId");
350       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo));
351       RETVALUE (RFAILED);
352    }
353
354    ret = ROK;
355
356    cpjSap = &(tPjCb->u.ulCb->cpjSap);
357    if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cpjReEstCfm, 
358       sizeof (CpjReEstCfmInfo)) != ROK)
359    {
360       /* Free memory for CfgReqInfo */
361       /* kw002.201 Freeing from proper region */  
362       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo));
363       PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->reEstReq, sizeof(CpjReEstReqInfo));
364       PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
365       RLOG0(L_FATAL, "Memory Allocation failed.");
366       RETVALUE(RFAILED);
367    }
368
369    cpjReEstCfm->ueId = cfgInfo->reEstReq->pdcpId.ueId;
370    cpjReEstCfm->cellId = cfgInfo->reEstReq->pdcpId.cellId;
371    /* Assign number of entity configuraitons and suId */
372    cpjReEstCfm->transId = cfgInfo->uprLyrTransId;
373    cpjReEstCfm->status = reEstCfm->status;
374    
375    if (CPJ_CFG_CFM_OK == reEstCfm->status)
376    {
377       /* handle ReEstablish here */
378       pjCfgUlReEstReq(tPjCb, cfgInfo->reEstReq, cpjReEstCfm);
379    }
380
381 #ifndef PJ_ASYNC_CFM
382    PjUiCpjReEstCfm(&(cpjSap->pst), cpjSap->suId, cpjReEstCfm);
383 #endif
384    /* Configuration information needs to be freed from proper region */
385    PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo));
386    PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->reEstReq, sizeof(CpjReEstReqInfo));
387    PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
388
389    RETVALUE(ROK);
390 }
391
392
393
394 #ifdef ANSI
395 PUBLIC S16 PjUlUdxSecCfgCfm
396 (
397 Pst * pst,
398 SuId suId,
399 UdxSecCfgCfmInfo * secCfgCfm
400 )
401 #else
402 PUBLIC S16 PjUlUdxSecCfgCfm(pst, suId, secCfgCfm)
403 Pst * pst;
404 SuId suId;
405 UdxSecCfgCfmInfo * secCfgCfm;
406 #endif
407 {
408    S16         ret;
409    CpjSecCfgCfmInfo  *cfgCfm;       /* Security Cfg Confirm structure */
410    PjCpjSapCb          *cpjSap;
411    PjCb            *tPjCb;
412    PjCfgInfo       *cfgInfo;
413    CpjSecCfgReqInfo *secCfg;
414 #ifdef PJ_SEC_ASYNC
415    PjUlUeCb               *ueCb = NULLP;
416 #endif
417
418    TRC3(PjUlUdxSecCfgCfm)
419
420 #if (ERRCLASS & ERRCLS_INT_PAR)
421    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
422    {
423       RETVALUE (RFAILED);
424    }
425 #endif
426    tPjCb = PJ_GET_PJCB(pst->dstInst);
427
428 #ifdef DEBUGP
429    RLOG1(L_DEBUG, "PjUlUdxUeIdChgCfm(post, suId(%d), ", suId);
430 #endif
431
432 #if (ERRCLASS & ERRCLS_INT_PAR)
433    if (suId < 0)
434    {
435       /* INNC: ERROR CLASS */
436       RLOG0(L_ERROR, "Invalid suId");
437       RETVALUE(RFAILED);
438    }
439 #endif /* ERRCLASS & ERRCLS_INT_PAR */
440
441    cpjSap = &(tPjCb->u.ulCb->cpjSap);
442
443    ret = pjDbmFindUlTransIdLst(tPjCb,secCfgCfm->transId, &cfgInfo);
444    if (ret != ROK)
445    {
446       RLOG0(L_ERROR, "Invalid transId");
447       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,secCfgCfm, sizeof (UdxSecCfgCfmInfo));
448       RETVALUE (RFAILED);
449    }
450
451    secCfg = cfgInfo->secCfgInfo;
452
453
454    if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfgCfm,
455       sizeof (CpjSecCfgCfmInfo)) != ROK)
456    {
457       /* Free memory for CfgReqInfo */
458       /* kw002.201 Freeing from proper region */  
459       PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, secCfg, sizeof(CpjSecCfgReqInfo));
460       PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
461       RLOG0(L_FATAL, "Memory Allocation failed.");
462       RETVALUE(RFAILED);
463    }
464
465    if ( pjCfgPrcSecUlCfg(tPjCb,secCfg,cfgCfm) != ROK )
466    {
467       RLOG_ARG2(L_ERROR,DBG_UEID,secCfg->ueId, 
468           "PjUiCpjSecCfgReq  cellId(%d) pjCfgSecCfg Failed: reason (%d)",
469             secCfg->cellId, cfgCfm->reason);
470
471    }
472    else
473    {
474         if (secCfgCfm->status != CPJ_CFG_CFM_OK)
475         {
476             PJ_MEM_CPY(cfgCfm, secCfgCfm, sizeof (CpjSecCfgCfmInfo));             
477         }
478    }
479    
480    cfgCfm->transId = cfgInfo->uprLyrTransId;
481 #ifdef PJ_SEC_ASYNC
482    ret = pjDbmFetchUlUeCb(tPjCb,secCfg->ueId, secCfg->cellId, &ueCb);
483    if ( ueCb != NULLP )
484    {
485       pjUtlUlSaveCfmInfo(tPjCb, ueCb, PJ_SEC_ASYNC_CFM, TRUE,  ENTPJ, (PTR)cfgCfm, NULLP);
486       PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgCfm, sizeof(CpjSecCfgCfmInfo));
487    }
488    else
489    {
490       RLOG_ARG1(L_ERROR, DBG_CELLID, secCfg->cellId,"UeId[%u] not found",
491             secCfg->ueId);
492       PjUiCpjSecCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm);
493    }
494 #else
495    PjUiCpjSecCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm);
496 #endif 
497
498   /* Configuration information needs to be freed from proper region */
499    PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,secCfgCfm, sizeof (UdxSecCfgCfmInfo));
500    PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, secCfg, sizeof(CpjSecCfgReqInfo));
501    PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
502
503    RETVALUE(ROK);
504 }
505
506 #ifdef ANSI
507 PUBLIC S16 PjUlUdxUeIdChgCfm
508 (
509 Pst * pst,
510 SuId suId,
511 U32 transId,
512 UdxUeInfo  * ueInfo,
513 CmStatus status
514 )
515 #else
516 PUBLIC S16 PjUlUdxUeIdChgCfm(pst, suId, transId, ueInfo, status)
517 Pst * pst;
518 SuId suId;
519 U32 transId;
520 UdxUeInfo  * ueInfo;
521 CmStatus status;
522 #endif
523 {
524    S16         ret;
525    CmStatus    tStatus;
526    PjCpjSapCb          *cpjSap;
527    PjCb            *tPjCb;
528    PjCfgInfo       *cfgInfo;
529
530    TRC3(PjUlUdxUeIdChgCfm)
531
532 #if (ERRCLASS & ERRCLS_INT_PAR)
533    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
534    {
535       RETVALUE (RFAILED);
536    }
537 #endif
538    tPjCb = PJ_GET_PJCB(pst->dstInst);
539
540 #ifdef DEBUGP
541    RLOG1(L_DEBUG, "PjUlUdxUeIdChgCfm(post, suId(%d), ", suId);
542 #endif
543
544 #if (ERRCLASS & ERRCLS_INT_PAR)
545    if (suId < 0)
546    {
547       /* INNC: ERROR CLASS */
548       RLOG0(L_ERROR, "Invalid suId");
549       RETVALUE(RFAILED);
550    }
551 #endif /* ERRCLASS & ERRCLS_INT_PAR */
552
553    ret = pjDbmFindUlTransIdLst(tPjCb, transId, &cfgInfo);
554    if (ret != ROK)
555    {
556       RLOG0(L_ERROR, "Invalid transId");
557       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,ueInfo, sizeof (UdxUeInfo));
558       RETVALUE (RFAILED);
559    }
560
561    ret = ROK;
562    tStatus.reason = CPJ_CFG_REAS_NONE;
563    tStatus.status = CPJ_CFG_CFM_OK;
564
565    if ( (ret = pjCfgUlUeIdChng(tPjCb,cfgInfo->ueInfo,
566                       cfgInfo->newUeInfo, &tStatus)) != ROK)
567    {
568 #ifdef DEBUGP
569       RLOG_ARG4(L_ERROR,DBG_UEID,cfgInfo->ueInfo->ueId, "Cpj UeId Chg Req"
570             " old-ueId(%d), new-ueId(%d), cellId(%d))Failed: reason (%d)",
571              cfgInfo->ueInfo->ueId, cfgInfo->newUeInfo->ueId,
572              cfgInfo->newUeInfo->cellId, status.reason);
573 #endif
574    }
575
576    cpjSap = &(tPjCb->u.ulCb->cpjSap);
577
578    if ((status.status == CPJ_CFG_CFM_OK) || 
579          (tStatus.status == CPJ_CFG_CFM_OK))
580    {
581       tStatus.reason = CPJ_CFG_REAS_NONE;
582       tStatus.status = CPJ_CFG_CFM_OK;
583    }
584  
585    PjUiCpjUeIdChgCfm(&cpjSap->pst,cpjSap->suId,cfgInfo->uprLyrTransId,(CpjUeInfo *)ueInfo,tStatus);
586
587    /* Free the buffers allocated before returning */
588    PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->ueInfo, sizeof(CpjUeInfo));
589    PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->newUeInfo, sizeof(CpjUeInfo));
590    PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
591
592
593    RETVALUE(ROK);
594 }
595
596 #ifdef ANSI
597 PUBLIC S16 PjUlUdxCountCfm
598 (
599 Pst * pst,
600 SuId suId,
601 UdxCountCfmInfo *cntCfm
602 )
603 #else
604 PUBLIC S16 PjUlUdxCountCfm(pst, suId, cntCfm) 
605 Pst * pst;
606 SuId suId;
607 UdxCountCfmInfo *cntCfm;
608 #endif
609 {
610
611    S16         ret;
612    PjCpjSapCb          *cpjSap;
613    PjCb            *tPjCb;
614    PjCfgInfo       *cfgInfo;
615    CpjCountReqInfo   *countReq = NULLP;
616    CpjCountCfmInfo *countCfm = NULLP;
617
618    TRC3(PjUlUdxCountCfm)
619
620 #if (ERRCLASS & ERRCLS_INT_PAR)
621    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
622    {
623       RETVALUE (RFAILED);
624    }
625 #endif
626    tPjCb = PJ_GET_PJCB(pst->dstInst);
627
628 #ifdef DEBUGP
629    RLOG1(L_DEBUG, "PjUlUdxUeIdChgCfm(post, suId(%d), ", suId);
630 #endif
631
632 #if (ERRCLASS & ERRCLS_INT_PAR)
633    if (suId < 0)
634    {
635       /* INNC: ERROR CLASS */
636       RLOG0(L_ERROR, "Invalid suId");
637       RETVALUE(RFAILED);
638    }
639 #endif /* ERRCLASS & ERRCLS_INT_PAR */
640
641    ret = pjDbmFindUlTransIdLst(tPjCb, cntCfm->transId, &cfgInfo);
642    if (ret != ROK)
643    {
644       RLOG0(L_ERROR, "Invalid transId");
645       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cntCfm, sizeof (UdxCountCfmInfo));
646       RETVALUE (RFAILED);
647    }
648    cpjSap = &tPjCb->u.ulCb->cpjSap;   
649    countReq = cfgInfo->cntReq;
650    if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&countCfm,
651       sizeof (CpjCountCfmInfo)) != ROK)
652    {   
653       /* Free memory for CfgReqInfo */
654       /* kw002.201 Freeing from proper region */
655      /* ccpu00136902 */
656    /*   PJ_PST_FREE(pst->region, pst->pool, countReq, sizeof(CpjCountReqInfo)); */
657       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cntCfm, sizeof (UdxCountCfmInfo));
658       PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, countReq, sizeof(CpjCountReqInfo));    
659       PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));  /*MEM_LEAK_FIX */
660       RLOG0(L_FATAL, "Memory Allocation failed.");
661
662       RETVALUE(RFAILED);
663    }
664    PJ_MEM_CPY(countCfm, cntCfm, sizeof(CpjCountCfmInfo));      /* KW_FIX */
665    if ( pjCfgPrcUlCount(tPjCb, countReq, countCfm, cntCfm) != ROK )
666    {
667       RLOG_ARG2(L_ERROR,DBG_UEID,countReq->ueId, 
668             "PjUiCpjCountReq cellId(%d)  pjCfgSecCfg Failed: reason (%d)",
669                 countReq->cellId, countCfm->reason);
670
671    }
672
673    countCfm->transId = cfgInfo->uprLyrTransId;
674    /* Ned to consolidate confirms */
675    /* Freeing from proper region */
676    
677    PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cntCfm, sizeof (UdxCountCfmInfo));
678    PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, countReq, sizeof(CpjCountReqInfo));    
679    PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));  /*MEM_LEAK_FIX */
680
681
682    PjUiCpjCountCfm(&(cpjSap->pst), cpjSap->suId,countCfm);
683
684    RETVALUE(ROK);
685 }
686
687 #ifdef ANSI
688 PUBLIC S16 PjUlUdxSduStaCfm
689 (
690 Pst              *pst,
691 SuId              suId,
692 UdxSduStaCfmInfo *staCfm
693 )
694 #else
695 PUBLIC S16 PjUlUdxSduStaCfm(pst, suId, staCfm)
696 Pst              *pst;
697 SuId              suId;
698 UdxSduStaCfmInfo *staCfm;
699 #endif
700 {
701    S16                ret;
702    PjCpjSapCb        *cpjSap;
703    PjCb              *tPjCb;
704    PjCfgInfo         *cfgInfo;
705    CpjSduStaReqInfo  *staReq;  
706    CpjSduStaCfmInfo  *sduStaCfm;
707
708    TRC3(PjUlUdxSduStaCfm)
709
710 #if (ERRCLASS & ERRCLS_INT_PAR)
711    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
712    {
713       RETVALUE (RFAILED);
714    }
715 #endif
716    tPjCb = PJ_GET_PJCB(pst->dstInst);
717
718 #ifdef DEBUGP
719    RLOG1(L_DEBUG, "PjUlUdxSduStaCfm(post, suId(%d), ", suId); 
720 #endif
721
722 #if (ERRCLASS & ERRCLS_INT_PAR)
723    if (suId < 0)
724    {
725       /* INNC: ERROR CLASS */
726       RLOG0(L_ERROR, "Invalid suId");
727       RETVALUE(RFAILED);
728    }
729 #endif /* ERRCLASS & ERRCLS_INT_PAR */
730
731    cpjSap = &(tPjCb->u.ulCb->cpjSap);
732    ret = pjDbmFindUlTransIdLst(tPjCb, staCfm->transId, &cfgInfo);
733    if (ret != ROK)
734    {
735       RLOG0(L_ERROR, "Invalid transId");
736       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,staCfm, sizeof (UdxSduStaCfmInfo));
737       RETVALUE (RFAILED);
738    }
739
740    staReq = cfgInfo->staReq;
741    
742    if (ROK == staCfm->status)
743    {
744       if (pjCfgPrcUlSduSta(tPjCb, staReq, staCfm) != ROK )
745       {
746          RLOG_ARG1(L_ERROR,DBG_UEID,staReq->ueId, 
747              "PjUlUdxSduStaReq ,cellId(%d) pjCfgSecCfg Failed",staReq->cellId);
748          /* Memory leak fix ccpu00135359 */
749          PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,staCfm, sizeof (UdxSduStaCfmInfo));
750          ret = RFAILED;
751       }
752    }
753    else
754    {
755       /* Memory leak fix ccpu00135359 */
756       if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&sduStaCfm, 
757          sizeof (CpjSduStaCfmInfo)) != ROK)
758       {
759          RLOG0(L_FATAL, "Memory Allocation failed.");
760          PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,staCfm, sizeof (UdxSduStaCfmInfo));
761          PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->staReq, sizeof(CpjSduStaReqInfo));
762          PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
763          RETVALUE(RFAILED);
764       }
765       sduStaCfm->ueId   = staCfm->ueId; 
766       sduStaCfm->cellId = staCfm->cellId;
767       sduStaCfm->transId = cfgInfo->uprLyrTransId;
768       sduStaCfm->status = RFAILED;
769       sduStaCfm->reason = staCfm->reason; 
770       sduStaCfm->numRb = staCfm->numRb; 
771
772       RLOG_ARG1(L_DEBUG,DBG_UEID,staCfm->ueId, 
773             "PjUlUdxSduStaCfm- UdxSduStaCfm fail - cellId(%d)",staCfm->cellId);
774
775       PjUiCpjSduStaCfm(&(cpjSap->pst), cpjSap->suId, sduStaCfm); 
776       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,staCfm, sizeof (UdxSduStaCfmInfo));
777    }
778
779    PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->staReq, sizeof(CpjSduStaReqInfo));
780    PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
781
782    RETVALUE(ROK);
783 }
784
785 #ifdef ANSI
786 PUBLIC S16 PjUlUdxDatResumeCfm
787 (
788 Pst                   *pst,
789 SuId                  suId,
790 UdxDatResumeCfmInfo   *udxDatResumeCfm
791 )
792 #else
793 PUBLIC S16 PjUlUdxDatResumeCfm(pst, suId, udxDatResumeCfm)
794 Pst                   *pst;
795 SuId                  suId;
796 UdxDatResumeCfmInfo   *udxDatResumeCfm;
797 #endif
798 {
799    S16                ret;
800    PjCpjSapCb        *cpjSap;
801    PjCb              *tPjCb;
802    PjCfgInfo         *cfgInfo;
803    CpjDatResumeReqInfo  *datResReq;  
804    CpjDatResumeCfmInfo  *datResumeCfmInfo;
805
806    TRC3(PjUlUdxDatResumeCfm)
807
808 #if (ERRCLASS & ERRCLS_INT_PAR)
809    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
810    {
811       RETVALUE (RFAILED);
812    }
813 #endif
814    tPjCb = PJ_GET_PJCB(pst->dstInst);
815
816 #ifdef DEBUGP
817    RLOG1(L_DEBUG, "PjUlUdxDatResumeCfm(post, suId(%d), ", suId); 
818 #endif
819
820 #if (ERRCLASS & ERRCLS_INT_PAR)
821    if (suId < 0)
822    {
823       /* INNC: ERROR CLASS */
824       RLOG0(L_ERROR, "Invalid suId");
825       RETVALUE(RFAILED);
826    }
827 #endif /* ERRCLASS & ERRCLS_INT_PAR */
828
829    ret = pjDbmFindUlTransIdLst(tPjCb, udxDatResumeCfm->transId, &cfgInfo);
830    if (ret != ROK)
831    {
832       RLOG0(L_ERROR, "Invalid transId");
833       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,udxDatResumeCfm, sizeof (UdxDatResumeCfmInfo));
834       RETVALUE (RFAILED);
835    }
836
837    datResReq = cfgInfo->datResReq;
838    
839    pjUtlUlPrcsDatResume (tPjCb, datResReq);
840
841
842    /* Perform processing for filling up cfm structures */
843    cpjSap = &(tPjCb->u.ulCb->cpjSap);
844    if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&datResumeCfmInfo, 
845       sizeof (CpjDatResumeCfmInfo)) != ROK)
846    {
847       RLOG0(L_FATAL, "Memory Allocation failed.");
848       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,udxDatResumeCfm, sizeof (UdxDatResumeCfmInfo));
849       PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->datResReq, sizeof(CpjDatResumeReqInfo));
850       PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
851       RETVALUE(RFAILED);
852    }
853    datResumeCfmInfo->ueId = datResReq->ueId;
854    datResumeCfmInfo->cellId = datResReq->cellId;
855    datResumeCfmInfo->transId = datResReq->transId;
856    datResumeCfmInfo->status = CPJ_CFG_CFM_OK;
857    PjUiCpjDatResumeCfm(&(cpjSap->pst), cpjSap->suId, datResumeCfmInfo);
858
859    PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,udxDatResumeCfm, sizeof (UdxDatResumeCfmInfo));
860    PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->datResReq, sizeof(CpjDatResumeReqInfo));
861    PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo));
862
863    RETVALUE(ROK);
864 }
865
866 /**
867  * @brief
868  * This function processes Data Forwarding Confirm received from DL.
869  *
870  * Now the UL Module can start forwardng the UL Packets is Application 
871  * has requested for UL Data Forwarding.
872  *
873  *  @param[in] pst      post structure
874  *  @param[in] measType meas Type
875  *  @return S16
876  *      -# Success : ROK
877  *      -# Failure : RFAILED
878  */
879 #ifdef ANSI 
880 PUBLIC S16 PjUlUdxDatForwardCfm
881 (
882  Pst               *pst,
883  SuId              suId,
884  UdxDatFwdCfmInfo  *datFwdCfm
885  )
886 #else
887 PUBLIC S16 PjUlUdxDatForwardCfm(pst, suId, datFwdCfm)
888  Pst               *pst;
889  SuId              suId;
890  UdxDatFwdCfmInfo  *datFwdCfm;
891 #endif
892 {
893    PjCb        *tPjCb;
894    PjUlUeCb    *ueCb;
895    PjUlRbCb    *pjRbCb;
896    S16          ret;
897    U8           rbCnt = 0;
898
899    tPjCb = PJ_GET_PJCB(pst->dstInst);
900
901    ret = pjDbmFetchUlUeCb(tPjCb,datFwdCfm->ueId,
902          datFwdCfm->cellId, &ueCb);
903
904    /* Ue Cb is not present */
905    if( ROK != ret || NULLP == ueCb)
906    {
907       RLOG_ARG1(L_ERROR, DBG_CELLID, datFwdCfm->cellId,"UeId[%u] not found",
908             datFwdCfm->ueId);
909       PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdCfm, sizeof(UdxDatFwdCfmInfo));
910       RETVALUE(ret);
911    }
912
913    /* Forward UL Packets only if Application has requested */
914    if(ueCb->isUlDatFwdReqd == TRUE)
915    {
916       /* Call the UL Pkt Fwd Func for each Rab */
917       for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt++)
918       {
919          if((pjRbCb = ueCb->drbCb[rbCnt]) == NULLP)
920          {
921             continue;
922          }
923          /* UL Data Forwarding done only for AM Mode Bearers 
924           * datQ is in Buffer State and only during Handover */
925          if((pjRbCb->mode == PJ_DRB_AM) && (ueCb->libInfo.state == PJ_STATE_REEST_HO))
926          {
927             pjUlmStartDataFrwdPerRb(tPjCb, pjRbCb);
928          }
929       }
930    }
931
932    PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdCfm, sizeof(UdxDatFwdCfmInfo));
933    RETVALUE(ROK);
934 }
935
936
937 /**
938  *
939  * @brief 
940  *
941  *        Handler for Configuration Request on UL
942  *
943  * @b Description:
944  *
945  *        This function handles the configuration on UL after receiving 
946  *        the configuration confirm from DL.
947  *
948  *  @param[in] gCb     PDCP Instance Control block
949  *  @param[in] cfgInfo UL Configuration Info 
950  *  @param[in] cfmInfo Configuration Confirm Info 
951  *  @param[in] cfgCfm  Configuration Confirm Info 
952  *  @param[in] sndCfgCfm  Configuration Confirm Info 
953  *
954  *  @return  S16
955  *      -# ROK 
956  *      -# RFAILED
957  *
958  */
959
960 #ifdef ANSI
961 PRIVATE S16 pjHdlCpjUlCfgReq
962 (
963 PjCb         *gCb,
964 PjCfgInfo    *cfgInfo,
965 UdxCfgCfmInfo *cfmInfo,
966 CpjCfgCfmInfo *cfgCfm,
967 Bool           *sndCfgCfm
968 )
969 #else
970 PRIVATE S16 pjHdlCpjUlCfgReq(gCb, cfgInfo, cfmInfo, cfgCfm, sndCfgCfm)
971 PjCb         *gCb;
972 PjCfgInfo    *cfgInfo;
973 UdxCfgCfmInfo *cfmInfo;
974 CpjCfgCfmInfo *cfgCfm;
975 Bool           *sndCfgCfm;
976 #endif
977 {
978    CpjCfgReqInfo       *cfg;
979    U8                   idx;
980    Bool                 cfmType = 0;
981    Bool                 startTmr;
982    PjUlUeCb            *ueCb;       /* UE Control Block for storing the
983                                           cfg structure in case of ReEstablishment */ 
984    PjCpjSapCb          *cpjSap;
985
986    cfg = cfgInfo->cfgInfo;
987    startTmr  = FALSE;
988    ueCb      = NULLP;
989
990    /* Fetch UeCb */
991    pjDbmFetchUlUeCb(gCb, cfg->ueId, cfg->cellId, &ueCb);
992   /* KW_FIX : CPJ_MAX_CFG,CPJ_MAX_CFM,UDX_MAX_CFM have the same value , hence checking for only one of them */
993    for (idx = 0; idx < cfg->numEnt && idx < CPJ_MAX_CFG; idx++)
994    {
995       CpjCfmEnt  *entCfgCfm;
996       UdxCfmEnt  *entDlCfgCfm;
997       CpjCfgEnt  *entCfg;
998
999       entCfg  = &(cfg->cfgEnt[idx]);
1000       entCfgCfm   = &(cfgCfm->cfmEnt[idx]);
1001       entDlCfgCfm = &(cfmInfo->cfmEnt[idx]);
1002
1003       if (NULL != ueCb)
1004       {
1005             /* Fill the detault values here */
1006          PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, 
1007                    CPJ_CFG_CFM_OK,CPJ_CFG_REAS_NONE);
1008       }
1009       else
1010       {
1011          RLOG_ARG1(L_INFO, DBG_CELLID, cfg->cellId,"UeId[%u] not found",
1012             cfg->ueId);
1013          PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, 
1014                        CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN);
1015          if (entCfg->cfgType !=  CPJ_CFG_ADD)
1016          {
1017             /* all other requests require ueCb mandatorily */
1018             continue;
1019          }
1020        }
1021             
1022       switch (entCfg->cfgType)
1023       {
1024          case CPJ_CFG_ADD:
1025             {
1026                if (entCfg->m.addCfg.rlcInfo.dir & PJ_DIR_UL)
1027                {
1028                   U8 isHo;
1029                   isHo = cfg->isHo;
1030                   /* Add a new RB entity configuration */
1031                   if (pjCfgAddUlRb(gCb,cfg->ueId, cfg->cellId, isHo,
1032                               entCfg, &ueCb, entCfgCfm) != ROK)
1033                   {
1034 #ifdef DEBUGP
1035                       RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId,"UL RB Addition for"
1036                             "cellId(%d),rbId(%d) Failed: reason (%d)",
1037                             cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
1038 #endif
1039                       PJ_CFG_FILL_CFG_CFM(entCfgCfm,entCfg->rbId,entCfg->rbType, 
1040                             CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN);
1041                   }
1042                   /* Only In case of DRB only we need to set this flag */
1043 #ifdef PJ_CMP_ASYNC
1044                   else if(PJ_DRB == entCfg->rbType)
1045                   {
1046                      if(entCfg->m.addCfg.hdrCompCfg.hdrCompUsed)
1047                      {
1048                         cfmType  |=  PJ_CFG_ASYNC_CFM;
1049                         startTmr =  TRUE;
1050                      }
1051                   }
1052 #endif /* PJ_CMP_ASYNC */
1053                   if (entCfg->m.addCfg.rlcInfo.dir & PJ_DIR_DL)
1054                   {
1055                       if (entDlCfgCfm->status != CPJ_CFG_CFM_OK)
1056                       {
1057                         PJ_MEM_CPY(entCfgCfm, entDlCfgCfm, 
1058                                          sizeof(CpjCfmEnt));      /* KW_FIX */
1059                       }
1060                   }
1061                }
1062                else if (entCfg->m.addCfg.rlcInfo.dir & PJ_DIR_DL)
1063                {
1064                  PJ_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(CpjCfmEnt));       /* KW_FIX */
1065                }
1066                break;
1067             }
1068
1069          case CPJ_CFG_MODIFY:
1070             {
1071                if ((entCfg->m.modCfg.bitFlag & 0x01) ||
1072                    (entCfg->m.modCfg.hoInfo.isHoPres & CPJ_HO_UL))
1073                {
1074                   /* Re-configure the existing RB entity configuration */
1075                   if (pjCfgReCfgUlRb(gCb,ueCb, entCfg, entCfgCfm) != ROK)
1076                   {
1077 #ifdef DEBUGP
1078                      RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId,"RB Config Modify HO"
1079                         "for cellId(%d), rbId(%d) Failed :reason (%d)",
1080                         cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
1081 #endif
1082                   }
1083 #ifdef PJ_CMP_ASYNC
1084                   else if(PJ_DRB == entCfg->rbType)
1085                   {
1086                      if(entCfg->m.modCfg.hdrCompCfg.hdrCompUsed)
1087                      {
1088                         cfmType  |=  PJ_CFG_ASYNC_CFM;
1089                         startTmr =  TRUE;
1090                      }
1091                   }
1092 #endif /* PJ_CMP_ASYNC */
1093                   if ((entCfg->m.modCfg.bitFlag & 0x02) ||
1094                      (entCfg->m.modCfg.hdrCompCfg.hdrCompUsed) ||
1095                      (entCfg->m.modCfg.hoInfo.isHoPres & CPJ_HO_DL))
1096                   {
1097                       if (entDlCfgCfm->status != CPJ_CFG_CFM_OK)
1098                       {
1099                         PJ_MEM_CPY(entCfgCfm, entDlCfgCfm, 
1100                                          sizeof(CpjCfmEnt)); 
1101                       }
1102                   }
1103                }
1104                else  if (entCfg->m.modCfg.hdrCompCfg.hdrCompUsed) 
1105                {
1106                   /* Re-configure the existing RB entity configuration */
1107                   if (pjCfgReCfgUlRb(gCb,ueCb, entCfg, entCfgCfm) != ROK)
1108                   {
1109 #ifdef DEBUGP
1110                      RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId,"UL RB Modify Normal"
1111                         " for cellId(%d), rbId(%d) Failed: reason (%d)",
1112                         cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
1113 #endif
1114                      if (entCfgCfm->reason == CPJ_CFG_REAS_PDCPID_UNKWN)
1115                      {
1116                        PJ_MEM_CPY(entCfgCfm, entDlCfgCfm,sizeof(CpjCfmEnt)); 
1117                      }
1118                   }
1119 #ifdef PJ_CMP_ASYNC
1120                   else if(PJ_DRB == entCfg->rbType)
1121                   {
1122                      if(entCfg->m.modCfg.hdrCompCfg.hdrCompUsed)
1123                      {
1124                         cfmType  |=  PJ_CFG_ASYNC_CFM;
1125                         startTmr =  TRUE;
1126                      }
1127                   }
1128 #endif /* PJ_CMP_ASYNC */
1129
1130                   if ((entDlCfgCfm->reason != CPJ_CFG_REAS_PDCPID_UNKWN) &&
1131                      (entDlCfgCfm->status != CPJ_CFG_CFM_OK))
1132                   {
1133                     /* send configuration to DL instance */
1134                     PJ_MEM_CPY(entCfgCfm, entDlCfgCfm,sizeof(CpjCfmEnt));     /* KW_FIX */
1135                   }
1136                }
1137                else  if ((entCfg->m.modCfg.bitFlag & 0x02) ||
1138                      (entCfg->m.modCfg.hoInfo.isHoPres & CPJ_HO_DL))
1139                {
1140                   /* send configuration to DL instance */
1141                   PJ_MEM_CPY(entCfgCfm, entDlCfgCfm,sizeof(CpjCfmEnt));  /* KW_FIX */
1142                }
1143                break;
1144             }
1145          case CPJ_CFG_DELETE:
1146             {
1147                /* Delete the existing RB entity configuration */
1148                if (pjCfgDelUlRb(gCb,ueCb,entCfg, entCfgCfm) != ROK)
1149                {
1150 #ifdef DEBUGP
1151                   RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "Ul RB Delete for"
1152                             "cellId(%d), rbId(%d) Failed: reason (%d)",
1153                       cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
1154 #endif
1155                }
1156                if ((entDlCfgCfm->status != CPJ_CFG_CFM_OK) || (entCfgCfm->status != CPJ_CFG_CFM_OK))
1157                {
1158                    PJ_MEM_CPY(entCfgCfm, entDlCfgCfm, 
1159                                     sizeof(CpjCfmEnt));   /* KW_FIX */
1160                }
1161                break;
1162             }
1163
1164          case CPJ_CFG_REESTABLISH:
1165             {
1166                /* Re-establish the existing RB entity configuration */
1167                if (pjCfgReEstUlRb(gCb,ueCb,entCfg, entCfgCfm, entDlCfgCfm) != ROK)
1168                {
1169                   RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "UL RB Re-establish "
1170                         "for cellId(%d), rbId(%d) Failed: reason (%d)",
1171                          cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
1172
1173                }
1174                else
1175                {
1176                   cfmType  |=  PJ_CFG_REEST_ASYNC_CFM;
1177                   startTmr = FALSE;
1178                }
1179                
1180                break;
1181             }
1182          case CPJ_CFG_DELETE_UE:
1183             {
1184                /* Delete all RB entity configuration under UE */
1185                if (pjCfgDelUlUe(gCb,ueCb,entCfg, entCfgCfm) != ROK)
1186                {
1187 #ifdef DEBUGP
1188                   RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "UL UE Delete for "
1189                        "cellId(%d), rbId(%d) Failed: reason (%d)",
1190                       cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason);
1191 #endif
1192                }
1193 #if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
1194                else
1195                {
1196                   /* Wait for any messages in the Demand q to be processed */
1197                   cfmType  |=  PJ_CFG_UEDEL_ASYNC_CFM;
1198                   startTmr =  TRUE;
1199                }
1200 #endif /* (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) */
1201                if (entDlCfgCfm->status == CPJ_CFG_CFM_OK)
1202                {
1203                    PJ_MEM_CPY(entCfgCfm, entDlCfgCfm,
1204                                     sizeof(CpjCfmEnt));    /* KW_FIX */
1205                }
1206                break;
1207             }
1208          default:
1209             {
1210                PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,
1211                            CPJ_CFG_CFM_NOK, CPJ_CFG_REAS_INVALID_CFG);
1212
1213 #ifdef DEBUGP
1214                RLOG_ARG4(L_ERROR,DBG_UEID,cfg->ueId, "Cfg Req with Invalid Cfg"
1215                      "Type cellId(%d), cfgType(%d), rbId(%d)) Failed: reason (%d)",
1216                      cfg->cellId, entCfg->cfgType,
1217                      cfg->cfgEnt[idx].rbId, CPJ_CFG_REAS_INVALID_CFG);
1218 #endif
1219             }
1220       }
1221      /* ccpu00137221 : KW Fix */
1222       if (NULLP == ueCb)
1223       {
1224          PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, 
1225                CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN);
1226       }
1227    }
1228
1229    /* Assign number of entity configuraitons and suId */
1230    cfgCfm->transId = cfgInfo->uprLyrTransId;
1231    cfgCfm->ueId = cfg->ueId;
1232    cfgCfm->cellId = cfg->cellId;
1233    cfgCfm->numEnt = cfg->numEnt;
1234    /* ccpu00137221 : KW Fix */
1235    if (NULLP == ueCb)
1236    {
1237       RETVALUE(ROK);
1238    }
1239
1240    if (cfmType & PJ_CFG_REEST_ASYNC_CFM)
1241    {
1242       if (ueCb->libInfo.numReEstCmp > 0)
1243       {
1244          if (ueCb->libInfo.numReEstCmp > ueCb->libInfo.numReEstDrb)
1245          {
1246             /* Error Case */
1247             ueCb->libInfo.numReEstDrb = 0;
1248             ueCb->libInfo.numReEstCmp = 0;
1249          } 
1250          else
1251          {
1252             ueCb->libInfo.numReEstDrb -= ueCb->libInfo.numReEstCmp;
1253             ueCb->libInfo.numReEstCmp = 0;
1254          }
1255       }
1256       if (ueCb->libInfo.numReEstDrb == 0)
1257       {
1258 #ifdef PJ_ASYNC_CFM
1259          pjUtlUlSaveCfmInfo(gCb, ueCb, cfmType, startTmr, ENTPJ, (PTR)cfgCfm, (PTR)cfg);
1260 #endif
1261          pjUtlUlUpdUpSecKeys(gCb, ueCb);
1262 #ifdef PJ_ASYNC_CFM
1263          /* Memory leak fix ccpu00135359 */
1264         cpjSap = &(tPjCb->u.ulCb->cpjSap);
1265         PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgCfm, sizeof(CpjCfgCfmInfo));
1266         *sndCfgCfm = FALSE;
1267 #endif
1268       }
1269       else
1270       {
1271          pjUtlUlSaveCfmInfo(gCb, ueCb, cfmType, startTmr, ENTPJ, (PTR)cfgCfm, (PTR)cfg);
1272          cpjSap = &(gCb->u.ulCb->cpjSap);
1273          PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgCfm, sizeof(CpjCfgCfmInfo));
1274          *sndCfgCfm = FALSE;
1275       }
1276    }
1277    else
1278    {
1279       if (cfmType != 0)
1280       {
1281          pjUtlUlSaveCfmInfo(gCb, ueCb, cfmType, startTmr, ENTPJ, (PTR)cfgCfm, (PTR)cfg);
1282          /* Memory leak fix ccpu00135359 */
1283          cpjSap = &(gCb->u.ulCb->cpjSap);
1284          PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgCfm, sizeof(CpjCfgCfmInfo));
1285          *sndCfgCfm = FALSE;
1286       }
1287    }
1288
1289    RETVALUE(ROK);
1290 }
1291
1292
1293 /********************************************************************30**
1294          End of file
1295 **********************************************************************/