U8, U16, U32 data type changes
[o-du/l2.git] / src / cm / kwu.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:    KWU Interface
22     
23         Type:    C file
24   
25         Desc:    This file Contains the packing and unpacking functions for
26                  KWU Interface
27  
28         File:    kwu.c
29   
30 *********************************************************************21*/
31 \f
32 /* header include files (.h) */
33 #include "common_def.h"
34 #ifdef TENB_SPLIT_ARCH
35 #include "ss_queue.h"
36 #include "ss_task.h"
37 #include "ss_msg.h"
38 #endif
39 #include "kwu.h"           /* KWU defines */
40
41 /* extern (.x) include files */
42 #ifdef TENB_SPLIT_ARCH
43 #include "ss_queue.x"
44 #include "ss_task.x"
45 #include "ss_msg.x"
46 #endif
47 #ifdef SS_RBUF
48 #include "ss_rbuf.h"
49 #include "ss_rbuf.x"
50 #endif /*SS_RBUF*/
51 #include "kwu.x"           /* KWU */
52
53 #ifdef LCKWU
54 \f
55 /****************************************************************************
56  *                      Packing Functions
57  ***************************************************************************/
58 #ifdef ANSI
59 S16 cmPkKwuBndReq
60 (
61 Pst * pst,
62 SuId suId,
63 SpId spId
64 )
65 #else
66 S16 cmPkKwuBndReq(pst, suId, spId)
67 Pst * pst;
68 SuId suId;
69 SpId spId;
70 #endif
71 {
72    S16    ret1;
73    Buffer *mBuf;
74
75
76    mBuf = NULLP;
77
78    if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK)
79    {
80 #if (ERRCLASS & ERRCLS_ADD_RES)
81       if(ret1 != ROK)
82       {
83          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
84                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
85                (ErrVal)EKWU001, (ErrVal)0, "SGetMsg() failed");
86       }
87 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
88       return (ret1);
89    }
90    CMCHKPKLOG(SPkS16, spId, mBuf, EKWU002, pst);
91    CMCHKPKLOG(SPkS16, suId, mBuf, EKWU003, pst);
92    pst->event = (Event) KWU_EVT_BND_REQ;
93    return (SPstTsk(pst,mBuf));
94 }
95
96 \f
97 #ifdef ANSI
98 S16 cmPkKwuBndCfm
99 (
100 Pst * pst,
101 SuId suId,
102 uint8_t status
103 )
104 #else
105 S16 cmPkKwuBndCfm(pst, suId, status)
106 Pst * pst;
107 SuId suId;
108 uint8_t status;
109 #endif
110 {
111    S16    ret1;
112    Buffer *mBuf;
113
114
115    mBuf = NULLP;
116
117    if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK)
118    {
119 #if (ERRCLASS & ERRCLS_ADD_RES)
120       if(ret1 != ROK)
121       {
122          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
123                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
124                (ErrVal)EKWU004, (ErrVal)0, "SGetMsg() failed");
125       }
126 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
127       return (ret1);
128    }
129
130    CMCHKPKLOG(oduUnpackUInt8, status, mBuf, EKWU005, pst);
131    CMCHKPKLOG(SPkS16, suId, mBuf, EKWU006, pst);
132    pst->event = (Event) KWU_EVT_BND_CFM;
133    return (SPstTsk(pst,mBuf));
134 }
135
136 \f
137 #ifdef ANSI
138 S16 cmPkKwuUbndReq
139 (
140 Pst * pst,
141 SuId suId,
142 Reason reason
143 )
144 #else
145 S16 cmPkKwuUbndReq(pst, suId, reason)
146 Pst * pst;
147 SuId suId;
148 Reason reason;
149 #endif
150 {
151    S16 ret1;
152    Buffer *mBuf;
153
154
155    mBuf = NULLP;
156
157    if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK)
158    {
159 #if (ERRCLASS & ERRCLS_ADD_RES)
160       if(ret1 != ROK)
161       {
162          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
163                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
164                (ErrVal)EKWU007, (ErrVal)0, "SGetMsg() failed");
165       }
166 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
167       return (ret1);
168    }
169    CMCHKPKLOG(SPkS16, reason, mBuf, EKWU008, pst);
170    CMCHKPKLOG(SPkS16, suId, mBuf, EKWU009, pst);
171
172    pst->event = (Event) KWU_EVT_UBND_REQ;
173    return (SPstTsk(pst,mBuf));
174 } /* cmPkKwuUbndReq */
175
176 #ifdef ANSI
177 uint8_t cmPkKwuDatReqInfo
178 (
179 KwuDatReqInfo *param,
180 Buffer *mBuf
181 )
182 #else
183 uint8_t cmPkKwuDatReqInfo(param, mBuf)
184 KwuDatReqInfo *param;
185 Buffer *mBuf;
186 #endif
187 {
188
189
190 #ifdef CCPU_OPT
191    switch(param->lcType) {
192       case CM_LTE_LCH_CCCH:
193          CMCHKPK(cmPkLteRnti, param->tm.rnti, mBuf);
194          break;
195       case CM_LTE_LCH_BCCH:
196       case  CM_LTE_LCH_PCCH:
197          CMCHKPK(cmPkLteTimingInfo, &param->tm.tmg, mBuf);
198 #ifdef EMTC_ENABLE
199          CMCHKPK(oduUnpackUInt8, param->emtcDiReason,mBuf);
200          CMCHKPK(oduUnpackUInt8, param->pnb,mBuf);
201 #endif
202          break;
203       case CM_LTE_LCH_DTCH:
204       case CM_LTE_LCH_DCCH:
205          break;
206       default :
207          return RFAILED;
208    }
209    CMCHKPK(cmPkLteLcType, param->lcType, mBuf);
210
211 #endif
212    CMCHKPK(oduUnpackUInt32, param->sduId, mBuf);
213    CMCHKPK(cmPkLteRlcId, &param->rlcId, mBuf);
214    return ROK;
215 } /* cmPkKwuDatReqInfo */
216
217 \f
218 #ifdef ANSI
219 uint8_t cmPkKwuDatReq
220 (
221 Pst * pst,
222 KwuDatReqInfo* datReq,
223 Buffer * mBuf
224 )
225 #else
226 uint8_t cmPkKwuDatReq(pst, datReq, mBuf)
227 Pst * pst;
228 KwuDatReqInfo* datReq;
229 Buffer * mBuf;
230 #endif
231 {
232 #ifdef LCKWU
233 #if (ERRCLASS & ERRCLS_ADD_RES)
234 #endif
235 #endif /* LCKWU */
236    S16 ret1 = ROK;
237 #ifndef SS_RBUF
238    KwuDatReqInfo* datReqInfo;
239 #endif
240 #ifndef SS_RBUF
241    switch(pst->selector)
242    {
243      case ODU_SELECTOR_LWLC:
244         {
245            if(pst->srcEnt == ENTDUAPP)
246            {
247              /* When the Selector is LWLC, we need to allocate memory, copy
248               * the contents and pass the pointer of the allocated memory. The
249               * subsequent free would be done during the Unpack function of the
250               * primitive. */
251             if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&datReqInfo,
252                         sizeof(KwuDatReqInfo),SS_SHARABLE_MEMORY)) != ROK)
253             {
254 #if (ERRCLASS & ERRCLS_ADD_RES)
255                if(ret1 != ROK)
256                {
257                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
258                         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
259                         (ErrVal)EKWU028, (ErrVal)0, "SGetMsg() failed");
260                }
261 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
262                return (ret1);
263             }
264             memcpy(datReqInfo,datReq,sizeof(KwuDatReqInfo));
265             CMCHKPK(oduPackPointer,(PTR)datReqInfo, mBuf);
266            }
267            else
268            {
269             CMCHKPK(oduPackPointer,(PTR)datReq, mBuf);
270            }
271         }
272         break;
273      case ODU_SELECTOR_LC:
274         {
275 #if (ERRCLASS & ERRCLS_ADD_RES)
276            ret1 = cmPkKwuDatReqInfo( (datReq), mBuf);
277            if(ret1 != ROK)
278            {
279               SPutMsg(mBuf);
280               SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
281                     __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
282                     (ErrVal)EKWU010, (ErrVal)ret1, "Packing failure");
283               return ( ret1 );
284            }
285 #else
286            cmPkKwuDatReqInfo( (datReq), mBuf);
287 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
288            if(pst->srcEnt == ENTNH)
289            {
290               if (SPutStaticBuffer(pst->region, pst->pool, (Data *)datReq,
291                        sizeof(KwuDatReqInfo),SS_SHARABLE_MEMORY) != ROK)
292               {
293                  SPutMsg(mBuf);
294                  return RFAILED;
295               }
296            }
297         }
298         break;
299      default:
300           SPutMsg(mBuf);
301 #if (ERRCLASS & ERRCLS_ADD_RES)
302           SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
303                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
304                (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n");
305 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
306           return RFAILED;
307    }
308
309 #ifdef L2_L3_SPLIT
310     if(datReq->rlcId.rbType == CM_LTE_SRB)
311     {
312        pst->event = (Event) KWU_EVT_CPLANE_DAT_REQ;
313     }
314     else
315     {
316        pst->event = (Event) KWU_EVT_UPLANE_DAT_REQ;
317     }
318 #else
319     pst->event = (Event) KWU_EVT_DAT_REQ;
320 #endif
321     return (SPstTsk(pst,mBuf));
322 #else
323    if (pst->srcEnt == ENTPJ)
324    {
325       Void *elem = NULLP;
326       KwuDatReqDetl *kwuDatReqDetl = NULLP;
327       elem = SRngGetWIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
328       if (NULLP != elem)
329       {
330          kwuDatReqDetl = (KwuDatReqDetl *) elem;
331          kwuDatReqDetl->spId = spId;
332          kwuDatReqDetl->lcType = datReq->lcType;
333          kwuDatReqDetl->sduId = datReq->sduId;
334          kwuDatReqDetl->rlcId = datReq->rlcId;
335          kwuDatReqDetl->mBuf = mBuf;
336          SRngIncrWIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
337          SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].pktRate++;
338          ret1 = ROK;
339       }
340       else
341       {
342          SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].pktDrop++;
343          SPutMsg(mBuf);
344          ret1 = RFAILED;
345       }
346    }
347    else
348    {
349       switch(pst->selector)
350       {
351 #ifdef LCKWU
352          case ODU_SELECTOR_LC:
353             {
354                ret1 = cmPkKwuDatReqInfo( (datReq), mBuf);
355 #if (ERRCLASS & ERRCLS_ADD_RES)
356                if(ret1 != ROK)
357                {
358                   SPutMsg(mBuf);
359                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
360                         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
361                         (ErrVal)EKWU010, (ErrVal)ret1, "Packing failure");
362                   return ( ret1 );
363                }
364 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
365             }
366             break;
367          case ODU_SELECTOR_LWLC:
368             {
369                CMCHKPK(oduPackPointer,(PTR)datReq, mBuf);
370             }
371             break;
372 #endif /* LCKWU */
373       }
374
375       CMCHKPKLOG(SPkS16, spId, mBuf, EKWU011, pst);
376       pst->event = (Event) KWU_EVT_DAT_REQ;
377       ret1 = SPstTsk(pst,mBuf);
378       if(pst->selector == ODU_SELECTOR_LC)
379       {
380          if (SPutStaticBuffer(pst->region, pst->pool, (Data *)datReq,
381                   sizeof(KwuDatReqInfo),SS_SHARABLE_MEMORY) != ROK)
382          {
383             SPutMsg(mBuf);
384             return RFAILED;
385          }
386       }
387    }
388    return (ret1);
389 #endif
390 } /* cmPkKwuDatReq */
391
392 \f
393 #ifdef ANSI
394 uint8_t cmPkKwuDatIndInfo
395 (
396 KwuDatIndInfo *param,
397 Buffer *mBuf
398 )
399 #else
400 uint8_t cmPkKwuDatIndInfo(param, mBuf)
401 KwuDatIndInfo *param;
402 Buffer *mBuf;
403 #endif
404 {
405
406    CMCHKPK(oduUnpackUInt8, param->isOutOfSeq, mBuf);
407 #ifdef CCPU_OPT
408    CMCHKPK(cmPkLteRnti, param->tCrnti, mBuf);
409 #endif
410    CMCHKPK(cmPkLteRlcId, &param->rlcId, mBuf);
411    return ROK;
412 }
413
414 \f
415 #ifdef ANSI
416 uint8_t cmPkKwuDatInd
417 (
418 Pst * pst,
419 KwuDatIndInfo* datInd,
420 Buffer * mBuf
421 )
422 #else
423 uint8_t cmPkKwuDatInd(pst, datInd, mBuf)
424 Pst * pst;
425 KwuDatIndInfo* datInd;
426 Buffer * mBuf;
427 #endif
428 {
429 #ifdef LCKWU
430     S16 ret1 = ROK;
431 #endif /* LCKWU */
432 #ifdef TENB_SPLIT_ARCH
433 #ifdef SS_LOCKLESS_MEMORY
434     SsMsgInfo   *mInfo; 
435 #endif
436 #endif
437     KwuDatIndInfo *datIndInfo = NULLP;
438
439
440 #ifdef TENB_SPLIT_ARCH
441     /* SSI_CHANGES: */
442 #ifdef SS_LOCKLESS_MEMORY
443     mInfo = (SsMsgInfo *)mBuf->b_rptr;
444     mInfo->region = pst->region;
445 #endif /* SS_LOCKLESS_MEMORY */
446 #endif
447
448     switch(pst->selector)
449     {
450        case ODU_SELECTOR_LWLC:
451           {
452              /* When the Selector is LWLC, we need to allocate memory, copy
453               * the contents and pass the pointer of the allocated memory. The
454               * subsequent free would be done during the Unpack function of the
455               * primitive. */
456             if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&datIndInfo,
457                         sizeof(KwuDatIndInfo),SS_SHARABLE_MEMORY)) != ROK)
458             {
459 #if (ERRCLASS & ERRCLS_ADD_RES)
460                if(ret1 != ROK)
461                {
462                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
463                         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
464                         (ErrVal)EKWU028, (ErrVal)0, "SGetMsg() failed");
465                }
466 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
467                return (ret1);
468             }
469
470             memcpy(datIndInfo, datInd,sizeof(KwuDatIndInfo));
471             CMCHKPK(oduPackPointer,(PTR)datIndInfo, mBuf);
472           }
473           break;
474        case ODU_SELECTOR_LC:
475           {
476 #if (ERRCLASS & ERRCLS_ADD_RES)
477              ret1 = cmPkKwuDatIndInfo( (datInd), mBuf);
478              if(ret1 != ROK)
479              {
480                 SPutMsg(mBuf);
481                 SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
482                       __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
483                       (ErrVal)EKWU012, (ErrVal)ret1, "Packing failure");
484                 return ( ret1 );
485              }
486 #else
487              cmPkKwuDatIndInfo( (datInd), mBuf);
488 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
489           }
490           break;
491        default:
492           SPutMsg(mBuf);
493 #if (ERRCLASS & ERRCLS_ADD_RES)
494           SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
495                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
496                (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n");
497 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
498           return RFAILED;
499     }
500
501     pst->event = (Event) KWU_EVT_DAT_IND;
502
503     return (SPstTsk(pst,mBuf));
504 } /* cmPkKwuDatInd */
505
506 \f
507 #ifdef ANSI
508 S16 cmPkKwuDatCfmInfo
509 (
510 KwuDatCfmInfo *param,
511 Buffer *mBuf
512 )
513 #else
514 S16 cmPkKwuDatCfmInfo(param, mBuf)
515 KwuDatCfmInfo *param;
516 Buffer *mBuf;
517 #endif
518 {
519    register uint32_t iter;
520
521    for(iter = 0; iter < param->numSduIds; iter++)
522    {
523       CMCHKPK(oduUnpackUInt32, param->sduIds[iter], mBuf);
524    }
525    CMCHKPK(oduUnpackUInt32, param->numSduIds, mBuf);
526    CMCHKPK(cmPkLteRlcId, &param->rlcId, mBuf);
527    return ROK;
528 } /* cmPkKwuDatCfmInfo */
529
530 \f
531 #ifdef ANSI
532 S16 cmPkKwuDatCfm
533 (
534 Pst * pst,
535 SuId suId,
536 KwuDatCfmInfo* datCfm
537 )
538 #else
539 S16 cmPkKwuDatCfm(pst, suId, datCfm)
540 Pst * pst;
541 SuId suId;
542 KwuDatCfmInfo* datCfm;
543 #endif
544 {
545 #if (ERRCLASS & ERRCLS_ADD_RES)
546    S16 ret1= ROK;
547 #endif 
548    Buffer *mBuf;
549
550
551    mBuf = NULLP;
552
553    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
554       return RFAILED;
555    }
556
557    switch(pst->selector)
558    {
559       case ODU_SELECTOR_LWLC:
560          {
561             CMCHKPK(oduPackPointer,(PTR)datCfm, mBuf);
562          }
563          break;
564       case ODU_SELECTOR_LC:
565          {
566 #if (ERRCLASS & ERRCLS_ADD_RES)
567             ret1 = cmPkKwuDatCfmInfo( (datCfm), mBuf);
568             if(ret1 != ROK)
569             {
570                SPutMsg(mBuf);
571                SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
572                      __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
573                      (ErrVal)EKWU014, (ErrVal)ret1, "Packing failure");
574                return ( ret1 );
575             }
576 #else
577             cmPkKwuDatCfmInfo( (datCfm), mBuf);
578 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
579             if (SPutStaticBuffer(pst->region, pst->pool, (Data *)datCfm,
580                      sizeof(KwuDatCfmInfo),SS_SHARABLE_MEMORY) != ROK)
581             {
582                SPutMsg(mBuf);
583                return RFAILED;
584             }
585          }
586          break;
587       default:
588           SPutMsg(mBuf);
589 #if (ERRCLASS & ERRCLS_ADD_RES)
590           SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
591                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
592                (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n");
593 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
594           return RFAILED;
595    }
596
597     CMCHKPKLOG(SPkS16, suId, mBuf, EKWU015, pst);
598     pst->event = (Event) KWU_EVT_DAT_CFM;
599
600     return (SPstTsk(pst,mBuf));
601 } /* cmPkKwuDatCfm */
602
603 \f
604 #ifdef ANSI
605 S16 cmPkKwuDiscSduReq
606 (
607 Pst * pst,
608 SpId spId,
609 KwuDiscSduInfo* discSdu
610 )
611 #else
612 S16 cmPkKwuDiscSduReq(pst, spId, discSdu)
613 Pst * pst;
614 SpId spId;
615 KwuDiscSduInfo* discSdu;
616 #endif
617 {
618 #ifdef LCKWU
619    S16 ret1;
620 #endif /* LCKWU */
621    Buffer *mBuf;
622    KwuDiscSduInfo* discSduInfo = NULLP;
623
624    mBuf = NULLP;
625
626    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
627       return RFAILED;
628    }
629
630    switch(pst->selector)
631    {
632       case ODU_SELECTOR_LWLC:
633          {
634             /* When the Selector is LWLC, we need to allocate memory, copy
635              * the contents and pass the pointer of the allocated memory. The
636              * subsequent free would be done during the Unpack function of the
637              * primitive. */
638            if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&discSduInfo,
639                        sizeof(KwuDiscSduInfo),SS_SHARABLE_MEMORY)) != ROK)
640            {
641 #if (ERRCLASS & ERRCLS_ADD_RES)
642               if(ret1 != ROK)
643               {
644                  SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
645                        __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
646                         (ErrVal)EKWU028, (ErrVal)0, "SGetMsg() failed");
647               }
648 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
649               return (ret1);
650            }
651             
652            memcpy(discSduInfo, discSdu,sizeof(KwuDiscSduInfo));
653            CMCHKPK(oduPackPointer,(PTR)discSduInfo, mBuf);
654          }
655          break;
656       case ODU_SELECTOR_LC:
657          {
658 #if (ERRCLASS & ERRCLS_ADD_RES)
659             ret1 = cmPkKwuDiscSduInfo( (discSdu), mBuf);
660             if(ret1 != ROK)
661             {
662                SPutMsg(mBuf);
663                SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
664                      __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
665                      (ErrVal)EKWU016, (ErrVal)ret1, "Packing failure");
666                return ( ret1 );
667             }
668 #else
669             cmPkKwuDiscSduInfo( (discSdu), mBuf);
670 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
671              break;
672           }
673     }
674
675     CMCHKPKLOG(SPkS16, spId, mBuf, EKWU017, pst);
676     pst->event = (Event) KWU_EVT_DISC_SDU_REQ;
677
678     return (SPstTsk(pst,mBuf));
679 } /* cmPkKwuDiscSduReq */
680
681 \f
682 #ifdef ANSI
683 S16 cmPkKwuStaIndInfo
684 (
685 KwuStaIndInfo *param,
686 Buffer *mBuf
687 )
688 #else
689 S16 cmPkKwuStaIndInfo(param, mBuf)
690 KwuStaIndInfo *param;
691 Buffer *mBuf;
692 #endif
693 {
694    S16 i;
695
696
697    for (i = (param->numSdu - 1); i >= 0; i--)
698    {
699       CMCHKPK(oduUnpackUInt32, param->sduId[(uint16_t)i], mBuf);
700    }
701    CMCHKPK(oduUnpackUInt32, param->numSdu, mBuf);
702    CMCHKPK(cmPkLteRlcId, &param->rlcId, mBuf);
703    return ROK;
704 }
705
706 #ifdef ANSI
707 S16 cmPkKwuFlowCntrlIndInfo
708 (
709 KwuFlowCntrlIndInfo *param,
710 Buffer              *mBuf
711 )
712 #else
713 S16 cmPkKwuFlowCntrlIndInfo(param, mBuf)
714 KwuFlowCntrlIndInfo  *param;
715 Buffer               *mBuf;
716 #endif
717 {
718
719    CMCHKPK(oduUnpackUInt32, param->pktAdmitCnt, mBuf);   
720    CMCHKPK(cmPkLteRlcId, &param->rlcId, mBuf);
721
722    return ROK;
723 } /* cmPkKwuFlowCntrlIndInfo */
724
725 #ifdef ANSI
726 S16 cmUnpkKwuFlowCntrlIndInfo
727 (
728 KwuFlowCntrlIndInfo *param,
729 Buffer              *mBuf
730 )
731 #else
732 S16 cmUnpkKwuFlowCntrlIndInfo(param, mBuf)
733 KwuFlowCntrlIndInfo  *param;
734 Buffer               *mBuf;
735 #endif
736 {
737    
738    CMCHKUNPK(cmUnpkLteRlcId, &param->rlcId, mBuf);
739    CMCHKUNPK(oduPackUInt32, &param->pktAdmitCnt, mBuf);
740   
741    return ROK;
742 } /* cmUnpkKwuFlowCntrlIndInfo */
743
744 \f
745 #ifdef ANSI
746 S16 cmPkKwuStaInd
747 (
748 Pst * pst,
749 SuId suId,
750 KwuStaIndInfo* staInd
751 )
752 #else
753 S16 cmPkKwuStaInd(pst, suId, staInd)
754 Pst * pst;
755 SuId suId;
756 KwuStaIndInfo* staInd;
757 #endif
758 {
759 #ifdef LCKWU
760 #if (ERRCLASS & ERRCLS_ADD_RES)
761    S16 ret1 = ROK;
762 #endif
763 #endif /* LCKWU */
764    Buffer *mBuf;
765
766
767    mBuf = NULLP;
768
769    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
770       return RFAILED;
771    }
772
773     switch(pst->selector)
774     {
775        case ODU_SELECTOR_LWLC:
776           {
777              CMCHKPK(oduPackPointer,(PTR) staInd, mBuf);
778           }
779           break;
780        case ODU_SELECTOR_LC:
781           {
782 #if (ERRCLASS & ERRCLS_ADD_RES)
783              ret1 = cmPkKwuStaIndInfo( (staInd), mBuf);
784              if(ret1 != ROK)
785              {
786                 SPutMsg(mBuf);
787                 SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
788                       __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
789                       (ErrVal)EKWU018, (ErrVal)ret1, "Packing failure");
790                 return ( ret1 );
791              }
792 #else
793              cmPkKwuStaIndInfo( (staInd), mBuf);
794 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
795              if (SPutStaticBuffer(pst->region, pst->pool, (Data *)staInd,
796                       sizeof(KwuStaIndInfo),SS_SHARABLE_MEMORY) != ROK)
797              {
798                 SPutMsg(mBuf);
799                 return RFAILED;
800              }
801           }
802           break;
803        default:
804           SPutMsg(mBuf);
805 #if (ERRCLASS & ERRCLS_ADD_RES)
806           SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
807                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
808                (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n");
809 #endif
810           return RFAILED;
811     }
812
813     CMCHKPKLOG(SPkS16, suId, mBuf, EKWU019, pst);
814     pst->event = (Event) KWU_EVT_STA_IND;
815
816     return (SPstTsk(pst,mBuf));
817 } /* cmPkKwuStaInd */
818
819 \f
820 #ifdef ANSI
821 S16 cmPkKwuReEstCmpInd
822 (
823 Pst * pst,
824 SuId suId,
825 CmLteRlcId rlcId
826 )
827 #else
828 S16 cmPkKwuReEstCmpInd(pst, suId, rlcId)
829 Pst * pst;
830 SuId suId;
831 CmLteRlcId rlcId;
832 #endif
833 {
834 #ifdef LCKWU
835 #if (ERRCLASS & ERRCLS_ADD_RES)
836    S16 ret1;
837 #endif
838 #endif /* LCKWU */
839    Buffer *mBuf;
840
841
842    mBuf = NULLP;
843
844    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
845       return RFAILED;
846    }
847
848     switch(pst->selector)
849     {
850 #ifdef LCKWU
851        case ODU_SELECTOR_LC:
852           {
853 #if (ERRCLASS & ERRCLS_ADD_RES)
854              ret1 = cmPkLteRlcId( &rlcId, mBuf);
855              if(ret1 != ROK)
856              {
857                 SPutMsg(mBuf);
858                 SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
859                       __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
860                       (ErrVal)EKWU018, (ErrVal)ret1, "Packing failure");
861                 return ( ret1 );
862              }
863 #else
864              cmPkLteRlcId( &rlcId, mBuf);
865 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
866              break;
867           }
868 #endif /* LCKWU */
869     }
870
871     CMCHKPKLOG(SPkS16, suId, mBuf, EKWU019, pst);
872     pst->event = (Event) KWU_EVT_REEST_CMP_IND;
873
874     return (SPstTsk(pst,mBuf));
875 } /* cmPkKwuReEstCmpInd */
876
877 /* kwu_c_001.main_3 added support for L2 Measurement */
878 #ifdef ANSI
879 S16 cmPkKwuDiscSduCfm
880 (
881 Pst            *pst,
882 SpId           spId,
883 KwuDiscSduInfo *discCfmSdu
884 )
885 #else
886 S16 cmPkKwuDiscSduCfm(pst, spId, discCfmSdu)
887 Pst            *pst;
888 SpId           spId;
889 KwuDiscSduInfo *discCfmSdu;
890 #endif
891 {
892 #if (ERRCLASS & ERRCLS_ADD_RES)
893    S16 ret1 = ROK;
894 #endif
895    Buffer *mBuf;
896
897
898    mBuf = NULLP;
899
900    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
901       return RFAILED;
902    }
903
904    switch(pst->selector)
905    {
906       case ODU_SELECTOR_LWLC:
907          {
908             CMCHKPK(oduPackPointer,(PTR)discCfmSdu, mBuf);
909          }
910          break;
911       case ODU_SELECTOR_LC:
912          {
913 #if (ERRCLASS & ERRCLS_ADD_RES)
914             ret1 = cmPkKwuDiscSduInfo((discCfmSdu), mBuf);
915             if(ret1 != ROK)
916             {
917                SPutMsg(mBuf);
918                SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
919                      __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
920                      (ErrVal)ERRKWU, (ErrVal)ret1, "Packing failure");
921                return ( ret1 );
922             }
923 #else
924             cmPkKwuDiscSduInfo((discCfmSdu), mBuf);
925 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
926             if (SPutStaticBuffer(pst->region, pst->pool, (Data *)discCfmSdu,
927                      sizeof(KwuDiscSduInfo),SS_SHARABLE_MEMORY) != ROK)
928             {
929                SPutMsg(mBuf);
930                return RFAILED;
931             }
932          }
933          break;
934       default:
935          SPutMsg(mBuf);
936 #if (ERRCLASS & ERRCLS_ADD_RES)
937          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
938                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
939                (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n");
940 #endif
941           return RFAILED;
942    }
943
944    CMCHKPKLOG(SPkS16, spId, mBuf, ERRKWU, pst);
945    pst->event = (Event) KWU_EVT_DISC_SDU_CFM;
946
947    return (SPstTsk(pst,mBuf));
948 } /* cmPkKwuDiscSduCfm */
949 \f
950 #ifdef ANSI
951 S16 cmPkKwuFlowCntrlInd
952 (
953 Pst            *pst,
954 SuId           suId,
955 KwuFlowCntrlIndInfo *flowCntrlIndInfo
956 )
957 #else
958 S16 cmPkKwuFlowCntrlInd(pst, suId, flowCntrlIndInfo)
959 Pst            *pst;
960 SuId           suId;
961 KwuFlowCntrlIndInfo *flowCntrlIndInfo;
962 #endif
963 {
964    Buffer *mBuf;
965
966
967    mBuf = NULLP;
968
969    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
970    {
971       SPutStaticBuffer(pst->region, 
972                pst->pool, 
973                (Data *)flowCntrlIndInfo,
974                sizeof(KwuFlowCntrlIndInfo),0);
975       return RFAILED;
976    }
977 #ifdef LCKWU
978    switch(pst->selector)
979    {
980       case ODU_SELECTOR_LC:
981       {
982          cmPkKwuFlowCntrlIndInfo((flowCntrlIndInfo), mBuf);
983
984          if (SPutStaticBuffer(pst->region, 
985                       pst->pool, 
986                       (Data *)flowCntrlIndInfo,
987                       sizeof(KwuFlowCntrlIndInfo),0) != ROK)
988          {
989             SPutMsg(mBuf);
990             return RFAILED;
991          }
992       }
993       break;
994       
995       case ODU_SELECTOR_LWLC:
996       {
997          CMCHKPK(oduPackPointer,(PTR) flowCntrlIndInfo, mBuf);
998       }
999       break;
1000    }
1001 #endif
1002
1003    CMCHKPKLOG(SPkS16, suId, mBuf, ERRKWU, pst);
1004    pst->event = (Event) KWU_EVT_FLOW_CNTRL_IND;
1005
1006    return (SPstTsk(pst,mBuf));
1007 } /* cmPkKwuFlowCntrlInd */
1008
1009 #ifdef LTE_L2_MEAS
1010 #ifdef ANSI
1011 S16 cmPkKwuDatAckInfo
1012 (
1013 KwuDatAckInfo *param,
1014 Buffer *mBuf
1015 )
1016 #else
1017 S16 cmPkKwuDatAckInfo(param, mBuf)
1018 KwuDatAckInfo *param;
1019 Buffer *mBuf;
1020 #endif
1021 {
1022
1023    CMCHKPK(cmPkLteRlcId, &param->rlcId, mBuf);
1024    CMCHKPK(oduUnpackUInt32, param->sduId, mBuf);
1025    return ROK;
1026 }
1027
1028 #ifdef ANSI
1029 S16 cmPkKwuDatAckInd
1030 (
1031 Pst * pst,
1032 SuId suId,
1033 KwuDatAckInfo* datInd
1034 )
1035 #else
1036 S16 cmPkKwuDatAckInd(pst, suId, datInd)
1037 Pst * pst;
1038 SuId suId;
1039 KwuDatAckInfo* datInd;
1040 #endif
1041 {
1042     S16 ret1;
1043
1044    Buffer *mBuf;
1045
1046
1047    mBuf = NULLP;
1048
1049    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
1050       return RFAILED;
1051    }
1052
1053    ret1 = cmPkKwuDatAckInfo( (datInd), mBuf);
1054 #if (ERRCLASS & ERRCLS_ADD_RES)
1055    if(ret1 != ROK)
1056    {
1057       SPutMsg(mBuf);
1058       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1059             __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1060             (ErrVal)ERRKWU, (ErrVal)ret1, "Packing failure");
1061       return ( ret1 );
1062    }
1063 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
1064    if (SPutStaticBuffer(pst->region, pst->pool, (Data *)datInd,
1065             sizeof(KwuDatAckInfo),SS_SHARABLE_MEMORY) != ROK)
1066    {
1067       SPutMsg(mBuf);
1068       return RFAILED;
1069    }
1070
1071    CMCHKPKLOG(SPkS16, suId, mBuf, ERRKWU, pst);
1072    pst->event = (Event) KWU_EVT_DAT_ACK_IND;
1073
1074    return (SPstTsk(pst,mBuf));
1075 } /* cmPkKwuDatAckInd */
1076 #endif /* LTE_L2_MEAS */
1077
1078 \f
1079 #ifdef ANSI
1080 S16 cmUnpkKwuBndReq
1081 (
1082 KwuBndReq func,
1083 Pst *pst,
1084 Buffer *mBuf
1085 )
1086 #else
1087 S16 cmUnpkKwuBndReq(func, pst, mBuf)
1088 KwuBndReq func;
1089 Pst *pst;
1090 Buffer *mBuf;
1091 #endif
1092 {
1093    SuId suId = 0;
1094    SpId spId = 0;
1095
1096    CMCHKUNPKLOG(SUnpkS16, &suId, mBuf, EKWU020, pst);
1097    CMCHKUNPKLOG(SUnpkS16, &spId, mBuf, EKWU021, pst);
1098    SPutMsg(mBuf);
1099
1100    return ((*func)(pst, suId, spId));
1101 }
1102
1103 \f
1104 #ifdef ANSI
1105 S16 cmUnpkKwuBndCfm
1106 (
1107 KwuBndCfm func,
1108 Pst *pst,
1109 Buffer *mBuf
1110 )
1111 #else
1112 S16 cmUnpkKwuBndCfm(func, pst, mBuf)
1113 KwuBndCfm func;
1114 Pst *pst;
1115 Buffer *mBuf;
1116 #endif
1117 {
1118    SuId suId = 0;
1119    uint8_t status = 0;
1120
1121
1122    CMCHKUNPKLOG(SUnpkS16, &suId, mBuf, EKWU022, pst);
1123    CMCHKUNPKLOG(oduPackUInt8, &status, mBuf, EKWU023, pst);
1124    SPutMsg(mBuf);
1125
1126    return ((*func)(pst, suId, status));
1127 }
1128
1129 \f
1130 #ifdef ANSI
1131 S16 cmUnpkKwuUbndReq
1132 (
1133 KwuUbndReq func,
1134 Pst *pst,
1135 Buffer *mBuf
1136 )
1137 #else
1138 S16 cmUnpkKwuUbndReq(func, pst, mBuf)
1139 KwuUbndReq func;
1140 Pst *pst;
1141 Buffer *mBuf;
1142 #endif
1143 {
1144    SpId spId = 0;
1145    Reason reason = 0;
1146    
1147
1148    CMCHKUNPKLOG(SUnpkS16, &spId, mBuf, EKWU024, pst);
1149    CMCHKUNPKLOG(SUnpkS16, &reason, mBuf, EKWU025, pst);
1150    SPutMsg(mBuf);
1151
1152    return ((*func)(pst, spId, reason));
1153 } /* cmUnpkKwuUbndReq */
1154
1155 \f
1156 #ifdef ANSI
1157 S16 cmUnpkKwuDatReqInfo
1158 (
1159 KwuDatReqInfo *param,
1160 Buffer *mBuf
1161 )
1162 #else
1163 S16 cmUnpkKwuDatReqInfo(param, mBuf)
1164 KwuDatReqInfo *param;
1165 Buffer *mBuf;
1166 #endif
1167 {
1168
1169
1170    CMCHKUNPK(cmUnpkLteRlcId, &param->rlcId, mBuf);
1171    CMCHKUNPK(oduPackUInt32, &param->sduId, mBuf);
1172
1173 #ifdef CCPU_OPT
1174    CMCHKUNPK(cmUnpkLteLcType, &param->lcType, mBuf);
1175    switch(param->lcType) {
1176       case CM_LTE_LCH_BCCH:
1177       case  CM_LTE_LCH_PCCH:
1178 #ifdef EMTC_ENABLE
1179          CMCHKUNPK(oduPackUInt8,&param->pnb , mBuf);
1180          CMCHKUNPK(oduPackUInt8,&param->emtcDiReason , mBuf);
1181 #endif         
1182          CMCHKUNPK(cmUnpkLteTimingInfo, &param->tm.tmg, mBuf);
1183
1184          break;
1185       case CM_LTE_LCH_CCCH:
1186          CMCHKUNPK(cmUnpkLteRnti, &param->tm.rnti, mBuf);
1187          break;
1188       case CM_LTE_LCH_DTCH:
1189       case CM_LTE_LCH_DCCH:
1190          break;
1191       default :
1192          return RFAILED;
1193    }
1194 #endif
1195    return ROK;
1196 }
1197
1198 \f
1199 #ifdef ANSI
1200 S16 cmUnpkKwuDatReq
1201 (
1202 KwuDatReq func,
1203 Pst *pst,
1204 Buffer *mBuf
1205 )
1206 #else
1207 S16 cmUnpkKwuDatReq(func, pst, mBuf)
1208 KwuDatReq func;
1209 Pst *pst;
1210 Buffer *mBuf;
1211 #endif
1212 {
1213 #if(ERRCLASS & ERRCLS_DEBUG)
1214    S16 ret1 = ROK; 
1215 #endif
1216    S16 retVal;
1217    KwuDatReqInfo *datReq = NULLP;
1218    KwuDatReqInfo datReqTmp;
1219
1220
1221    switch(pst->selector)
1222    {
1223       case ODU_SELECTOR_LWLC:
1224          {
1225             CMCHKUNPK(oduUnpackPointer,(PTR *) &datReq, mBuf);
1226          }
1227          break;
1228       case ODU_SELECTOR_LC:
1229          {
1230             /* Allocate the memory statically  as there is no free 
1231              * in RLC */
1232             datReq = &datReqTmp;
1233             memset(datReq, 0, sizeof(KwuDatReqInfo));
1234 #if(ERRCLASS & ERRCLS_DEBUG)
1235             ret1 = cmUnpkKwuDatReqInfo( (datReq), mBuf);
1236             if(ret1 != ROK)
1237             {
1238                SPutMsg(mBuf);
1239                SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId,
1240                      __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
1241                      (ErrVal)EKWU027, (ErrVal)ret1, "Unpacking failure");
1242                return ( ret1 );
1243             }
1244 #else
1245             cmUnpkKwuDatReqInfo( (datReq), mBuf);
1246 #endif /* ERRCLASS & ERRCLS_DEBUG */
1247          }
1248          break;
1249       default:
1250          SPutMsg(mBuf);
1251 #if (ERRCLASS & ERRCLS_ADD_RES)
1252          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1253                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1254                (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n");
1255 #endif
1256          return RFAILED;
1257    }
1258
1259    retVal = (*func)(pst, datReq, mBuf);
1260    /* If LWLC is configured, we need to
1261     * free the memory here. */
1262    if(pst->selector == ODU_SELECTOR_LWLC)
1263    {
1264       retVal = SPutStaticBuffer(pst->region, pst->pool, (Data *)datReq,
1265             sizeof(KwuDatReqInfo),SS_SHARABLE_MEMORY);
1266    }
1267    return (retVal);
1268 } /* cmUnpkKwuDatReq */
1269
1270 \f
1271 #ifdef ANSI
1272 uint8_t cmUnpkKwuDatIndInfo
1273 (
1274 KwuDatIndInfo *param,
1275 Buffer *mBuf
1276 )
1277 #else
1278 uint8_t cmUnpkKwuDatIndInfo(param, mBuf)
1279 KwuDatIndInfo *param;
1280 Buffer *mBuf;
1281 #endif
1282 {
1283
1284    CMCHKUNPK(cmUnpkLteRlcId, &param->rlcId, mBuf);
1285
1286 #ifdef CCPU_OPT
1287    CMCHKUNPK(cmUnpkLteRnti, &param->tCrnti, mBuf);
1288 #endif
1289    CMCHKUNPK(oduPackUInt8, &param->isOutOfSeq, mBuf);
1290    return ROK;
1291 }
1292
1293 \f
1294 #ifdef ANSI
1295 uint8_t cmUnpkKwuDatInd
1296 (
1297 KwuDatInd func,
1298 Pst *pst,
1299 Buffer *mBuf
1300 )
1301 #else
1302 uint8_t cmUnpkKwuDatInd(func, pst, mBuf)
1303 KwuDatInd func;
1304 Pst *pst;
1305 Buffer *mBuf;
1306 #endif
1307 {
1308     S16 ret1 = ROK, retVal;
1309     KwuDatIndInfo *datInd = NULLP;
1310     KwuDatIndInfo datIndTmp;
1311     
1312
1313     switch(pst->selector)
1314     {
1315       case ODU_SELECTOR_LWLC:
1316          {
1317             CMCHKUNPK(oduUnpackPointer,(PTR *) &datInd, mBuf);
1318          }
1319          break;
1320       case ODU_SELECTOR_LC:
1321          {
1322             /*SGetStaticBuffer used as RRC has an equivalent free but PDCP
1323              * doesn't free any memory */
1324             if(pst->dstEnt != ENTPJ)
1325             {
1326                if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&datInd,
1327                            sizeof(KwuDatIndInfo),SS_SHARABLE_MEMORY)) != ROK)
1328                {
1329 #if (ERRCLASS & ERRCLS_ADD_RES)
1330        if(ret1 != ROK)
1331        {
1332           SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1333                 __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1334                (ErrVal)EKWU028, (ErrVal)0, "SGetMsg() failed");
1335        }
1336 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
1337                   return (ret1);
1338                }
1339             }
1340             else
1341             {
1342                datInd = &datIndTmp;
1343             }
1344
1345             ret1 = cmUnpkKwuDatIndInfo( (datInd), mBuf);
1346 #if(ERRCLASS & ERRCLS_DEBUG)
1347           if(ret1 != ROK)
1348           {
1349              SPutMsg(mBuf);
1350              SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId,
1351                    __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
1352                   (ErrVal)EKWU029, (ErrVal)ret1, "Unpacking failure");
1353              return ( ret1 );
1354           }
1355 #endif /* ERRCLASS & ERRCLS_DEBUG */
1356          }
1357          break;
1358       default:
1359          SPutMsg(mBuf);
1360          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1361                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1362                (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n");
1363          return RFAILED;
1364     }
1365     retVal = (*func)(pst, datInd, mBuf);
1366     /* If LWLC is configured and the destination entity is PDCP, we need to
1367      * free the memory here. */
1368     if((pst->selector == ODU_SELECTOR_LWLC) && (pst->dstEnt == ENTPJ))
1369     {
1370        retVal = SPutStaticBuffer(pst->region, pst->pool, (Data *)datInd,
1371                 sizeof(KwuDatIndInfo),SS_SHARABLE_MEMORY);
1372     }
1373     return (retVal);
1374 } /* cmUnpkKwuDatInd */
1375
1376 \f
1377 #ifdef ANSI
1378 S16 cmUnpkKwuDatCfmInfo
1379 (
1380 KwuDatCfmInfo *param,
1381 Buffer *mBuf
1382 )
1383 #else
1384 S16 cmUnpkKwuDatCfmInfo(param, mBuf)
1385 KwuDatCfmInfo *param;
1386 Buffer *mBuf;
1387 #endif
1388 {
1389    register S32 iter;
1390
1391    CMCHKUNPK(cmUnpkLteRlcId, &param->rlcId, mBuf);
1392    CMCHKUNPK(oduPackUInt32, &param->numSduIds, mBuf);
1393
1394 #ifdef L2_L3_SPLIT /*Work Around */
1395    if (param->numSduIds >= KWU_MAX_DAT_CFM)
1396       param->numSduIds = KWU_MAX_DAT_CFM;
1397 #endif
1398    for(iter = param->numSduIds -1; iter >= 0 ; iter--)
1399    {
1400       CMCHKUNPK(oduPackUInt32, &param->sduIds[iter], mBuf);
1401    }
1402    return ROK;
1403 }
1404
1405 #ifdef ANSI
1406 S16 cmUnpkKwuDatCfm
1407 (
1408 KwuDatCfm func,
1409 Pst *pst,
1410 Buffer *mBuf
1411 )
1412 #else
1413 S16 cmUnpkKwuDatCfm(func, pst, mBuf)
1414 KwuDatCfm func;
1415 Pst *pst;
1416 Buffer *mBuf;
1417 #endif
1418 {
1419    S16 ret1 = ROK;
1420    SuId          suId = 0;
1421    KwuDatCfmInfo *datCfm = NULLP;
1422
1423
1424    CMCHKUNPK(SUnpkS16, &(suId), mBuf);
1425
1426    switch(pst->selector)
1427    {
1428       case ODU_SELECTOR_LWLC:
1429          {
1430             CMCHKUNPK(oduUnpackPointer,(PTR *) &datCfm, mBuf);
1431          }
1432          break;
1433       case ODU_SELECTOR_LC:
1434          {
1435             if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&datCfm,\
1436                         sizeof(KwuDatCfmInfo),SS_SHARABLE_MEMORY)) != ROK)
1437             {
1438 #if (ERRCLASS & ERRCLS_ADD_RES)
1439        if(ret1 != ROK)
1440        {
1441           SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1442                 __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1443                (ErrVal)EKWU030, (ErrVal)0, "SGetMsg() failed");
1444        }
1445 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
1446                return (ret1);
1447             }
1448
1449             memset(datCfm, 0, sizeof(KwuDatCfmInfo));
1450             ret1 = cmUnpkKwuDatCfmInfo( (datCfm), mBuf);
1451 #if(ERRCLASS & ERRCLS_DEBUG)
1452           if(ret1 != ROK)
1453           {
1454              SPutMsg(mBuf);
1455              SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId,
1456                    __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
1457                   (ErrVal)EKWU031, (ErrVal)ret1, "Unpacking failure");
1458              return ( ret1 );
1459           }
1460 #endif /* ERRCLASS & ERRCLS_DEBUG */
1461          }
1462          break;
1463       default:
1464 #if (ERRCLASS & ERRCLS_ADD_RES)
1465           SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1466                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1467                (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n");
1468 #endif
1469           SPutMsg(mBuf);
1470           return RFAILED;
1471    }
1472
1473    SPutMsg(mBuf);
1474
1475    return ((*func)(pst, suId, datCfm));
1476 } /* cmUnpkKwuDatCfm */
1477
1478 \f
1479 #ifdef ANSI
1480 S16 cmUnpkKwuDiscSduReq
1481 (
1482 KwuDiscSduReq func,
1483 Pst *pst,
1484 Buffer *mBuf
1485 )
1486 #else
1487 S16 cmUnpkKwuDiscSduReq(func, pst, mBuf)
1488 KwuDiscSduReq func;
1489 Pst *pst;
1490 Buffer *mBuf;
1491 #endif
1492 {
1493    S16 ret1 = ROK;
1494    SpId          spId = 0;
1495    KwuDiscSduInfo *discSdu = NULLP;
1496
1497
1498    CMCHKUNPK(SUnpkS16, &(spId), mBuf);
1499    switch(pst->selector)
1500    {
1501       case ODU_SELECTOR_LWLC:
1502          {
1503             CMCHKUNPK(oduUnpackPointer,(PTR *) &discSdu, mBuf);
1504          }
1505          break;
1506       case ODU_SELECTOR_LC:
1507          {
1508             if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&discSdu,\
1509                         sizeof(KwuDiscSduInfo),SS_SHARABLE_MEMORY)) != ROK)
1510             {
1511 #if (ERRCLASS & ERRCLS_ADD_RES)
1512                /*MBUF_FIXX*/
1513                SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1514                      __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1515                      (ErrVal)EKWU032, (ErrVal)0, "SGetMsg() failed");
1516
1517 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
1518                return (ret1);
1519             }
1520
1521             memset(discSdu, 0, sizeof(KwuDiscSduInfo));
1522             ret1 = cmUnpkKwuDiscSduInfo( (discSdu), mBuf);
1523 #if(ERRCLASS & ERRCLS_DEBUG)
1524             if(ret1 != ROK)
1525             {
1526                SPutMsg(mBuf);
1527                SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId,
1528                      __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
1529                      (ErrVal)EKWU033, (ErrVal)ret1, "Unpacking failure");
1530                return ( ret1 );
1531             }
1532 #endif /* ERRCLASS & ERRCLS_DEBUG */
1533             break;
1534          }
1535       default:
1536 #if (ERRCLASS & ERRCLS_ADD_RES)
1537           SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1538                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1539                (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n");
1540 #endif
1541           SPutMsg(mBuf);
1542           return RFAILED;
1543    }
1544    SPutMsg(mBuf);
1545
1546    return ((*func)(pst, spId, discSdu));
1547 } /* cmUnpkKwuDiscSduReq */
1548
1549 \f
1550 #ifdef ANSI
1551 S16 cmUnpkKwuStaIndInfo
1552 (
1553 KwuStaIndInfo *param,
1554 Buffer *mBuf
1555 )
1556 #else
1557 S16 cmUnpkKwuStaIndInfo(param, mBuf)
1558 KwuStaIndInfo *param;
1559 Buffer *mBuf;
1560 #endif
1561 {
1562    uint32_t i;
1563
1564
1565    CMCHKUNPK(cmUnpkLteRlcId, &param->rlcId, mBuf);
1566    CMCHKUNPK(oduPackUInt32, &param->numSdu, mBuf);
1567    for (i = 0; i < param->numSdu; i++)
1568    {
1569       CMCHKUNPK(oduPackUInt32, &param->sduId[i], mBuf);
1570    }
1571
1572    return ROK;
1573 } /* cmUnpkKwuStaIndInfo */
1574
1575 \f
1576 #ifdef ANSI
1577 S16 cmUnpkKwuStaInd
1578 (
1579 KwuStaInd func,
1580 Pst *pst,
1581 Buffer *mBuf
1582 )
1583 #else
1584 S16 cmUnpkKwuStaInd(func, pst, mBuf)
1585 KwuStaInd func;
1586 Pst *pst;
1587 Buffer *mBuf;
1588 #endif
1589 {
1590    S16 ret1 = ROK;
1591    SuId          suId = 0;
1592    KwuStaIndInfo *staInd = NULLP;
1593
1594
1595    CMCHKUNPK(SUnpkS16, &(suId), mBuf);
1596    
1597    switch(pst->selector)
1598    {
1599       case ODU_SELECTOR_LWLC:
1600          {
1601             CMCHKUNPK(oduUnpackPointer,(PTR *)&staInd, mBuf);
1602          }
1603          break;
1604       case ODU_SELECTOR_LC:
1605          {
1606             if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&staInd,\
1607                         sizeof(KwuStaIndInfo),SS_SHARABLE_MEMORY)) != ROK)
1608             {
1609 #if (ERRCLASS & ERRCLS_ADD_RES)
1610                if(ret1 != ROK)
1611                {
1612                   SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1613                         __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1614                         (ErrVal)EKWU034, (ErrVal)0, "SGetMsg() failed");
1615                }
1616 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
1617                return (ret1);
1618             }
1619
1620             memset(staInd, 0, sizeof(KwuStaIndInfo));
1621
1622             ret1 = cmUnpkKwuStaIndInfo( (staInd), mBuf);
1623 #if(ERRCLASS & ERRCLS_DEBUG)
1624             if(ret1 != ROK)
1625             {
1626                SPutMsg(mBuf);
1627                SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId,
1628                      __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
1629                      (ErrVal)EKWU035, (ErrVal)ret1, "Unpacking failure");
1630                return ( ret1 );
1631             }
1632 #endif /* ERRCLASS & ERRCLS_DEBUG */
1633          }
1634          break;
1635       default:
1636           SPutMsg(mBuf);
1637 #if(ERRCLASS & ERRCLS_DEBUG)
1638           SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1639                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1640                (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n");
1641 #endif
1642           return RFAILED;
1643    }
1644    SPutMsg(mBuf);
1645
1646    return ((*func)(pst, suId, staInd));
1647 } /* cmUnpkKwuStaInd */
1648
1649 \f
1650 #ifdef ANSI
1651 S16 cmUnpkKwuReEstCmpInd
1652 (
1653 KwuReEstCmpInd func,
1654 Pst *pst,
1655 Buffer *mBuf
1656 )
1657 #else
1658 S16 cmUnpkKwuReEstCmpInd(func, pst, mBuf)
1659 KwuReEstCmpInd func;
1660 Pst *pst;
1661 Buffer *mBuf;
1662 #endif
1663 {
1664 #if(ERRCLASS & ERRCLS_DEBUG)
1665    S16 ret1;
1666 #endif
1667    SuId          suId = 0;
1668    CmLteRlcId    rlcId;
1669
1670    memset(&rlcId, 0, sizeof(CmLteRlcId));
1671    CMCHKUNPK(SUnpkS16, &(suId), mBuf);
1672    switch(pst->selector)
1673    {
1674 #ifdef LCKWU
1675       case ODU_SELECTOR_LC:
1676          {
1677 #if(ERRCLASS & ERRCLS_DEBUG)
1678             ret1 = cmUnpkLteRlcId( &rlcId, mBuf);
1679             if(ret1 != ROK)
1680             {
1681                SPutMsg(mBuf);
1682                SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId,
1683                      __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
1684                      (ErrVal)EKWU035, (ErrVal)ret1, "Unpacking failure");
1685                return ( ret1 );
1686             }
1687 #else
1688             cmUnpkLteRlcId( &rlcId, mBuf);
1689 #endif /* ERRCLASS & ERRCLS_DEBUG */
1690             break;
1691          }
1692 #endif /* LCKWU */
1693    }
1694    SPutMsg(mBuf);
1695
1696    return ((*func)(pst, suId, rlcId));
1697 } /* cmUnpkKwuReEstCmpInd */
1698
1699 /* kwu_c_001.main_3 added support for L2 Measurement */
1700 #ifdef ANSI
1701 S16 cmUnpkKwuDiscSduCfm
1702 (
1703 KwuDiscSduCfm  func,
1704 Pst            *pst,
1705 Buffer         *mBuf
1706 )
1707 #else
1708 S16 cmUnpkKwuDiscSduCfm(func, pst, mBuf)
1709 KwuDiscSduCfm  func;
1710 Pst            *pst;
1711 Buffer         *mBuf;
1712 #endif
1713 {
1714    S16 ret1 = ROK;
1715    SpId          spId = 0;
1716    KwuDiscSduInfo *discSdu = NULLP;
1717
1718
1719    CMCHKUNPK(SUnpkS16, &(spId), mBuf);
1720
1721    switch(pst->selector)
1722    {
1723       case ODU_SELECTOR_LWLC:
1724          {
1725             CMCHKUNPK(oduUnpackPointer,(PTR *) &discSdu, mBuf);
1726          }
1727          break;
1728       case ODU_SELECTOR_LC:
1729          {
1730             if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&discSdu,\
1731                         sizeof(KwuDiscSduInfo),SS_SHARABLE_MEMORY)) != ROK)
1732             {
1733 #if (ERRCLASS & ERRCLS_ADD_RES)
1734       if(ret1 != ROK)
1735       {
1736          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1737                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1738                (ErrVal)ERRKWU, (ErrVal)0, "SGetMsg() failed");
1739       }
1740 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
1741                return (ret1);
1742             }
1743             memset(discSdu, 0, sizeof(KwuDiscSduInfo));
1744
1745    ret1 = cmUnpkKwuDiscSduInfo( (discSdu), mBuf);
1746 #if(ERRCLASS & ERRCLS_DEBUG)
1747             if(ret1 != ROK)
1748             {
1749                SPutMsg(mBuf);
1750                SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1751                      __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1752                      (ErrVal)ERRKWU, (ErrVal)0, "SGetMsg() failed");
1753             }
1754 #endif /* ERRCLASS & ERRCLS_DEBUG */
1755          }
1756          break;
1757       default:
1758           SPutMsg(mBuf);
1759 #if(ERRCLASS & ERRCLS_DEBUG)
1760           SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1761                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1762                (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n");
1763 #endif
1764           return RFAILED;
1765    }
1766    SPutMsg(mBuf);
1767
1768    return ((*func)(pst, spId, discSdu));
1769 } /* cmUnpkKwuDiscSduCfm */
1770 #ifdef ANSI
1771 S16 cmUnpkKwuFlowCntrlInd
1772 (
1773 KwuFlowCntrlInd  func,
1774 Pst            *pst,
1775 Buffer         *mBuf
1776 )
1777 #else
1778 S16 cmUnpkKwuFlowCntrlInd(func, pst, mBuf)
1779 KwuFlowCntrlInd  func;
1780 Pst            *pst;
1781 Buffer         *mBuf;
1782 #endif
1783 {
1784    SuId   suId;
1785    KwuFlowCntrlIndInfo *flowCntrlInfo = NULLP;
1786
1787    
1788    CMCHKUNPK(SUnpkS16, &(suId), mBuf);
1789    switch(pst->selector)
1790    {
1791 #ifdef LCKWU
1792       case ODU_SELECTOR_LC:
1793       {
1794          if(SGetStaticBuffer(pst->region, 
1795                      pst->pool, 
1796                      (Data **)&flowCntrlInfo,
1797                      sizeof(KwuFlowCntrlIndInfo),0) != ROK)
1798          {
1799             SPutMsg(mBuf);
1800             return RFAILED;
1801          }
1802
1803          cmUnpkKwuFlowCntrlIndInfo(flowCntrlInfo, mBuf);
1804       }
1805       break;
1806
1807       case ODU_SELECTOR_LWLC:
1808       {
1809          CMCHKUNPK(oduUnpackPointer,(PTR *) &flowCntrlInfo, mBuf);
1810       }
1811       break;
1812 #endif
1813    }
1814
1815    SPutMsg(mBuf);
1816
1817    return ((*func)(pst, suId, flowCntrlInfo));
1818 } /* cmUnpkKwuFlowCntrlInd */
1819 #ifdef LTE_L2_MEAS
1820 \f
1821 #ifdef ANSI
1822 S16 cmUnpkKwuDatAckInfo
1823 (
1824 KwuDatAckInfo *param,
1825 Buffer *mBuf
1826 )
1827 #else
1828 S16 cmUnpkKwuDatAckInfo(param, mBuf)
1829 KwuDatAckInfo *param;
1830 Buffer *mBuf;
1831 #endif
1832 {
1833
1834    CMCHKUNPK(oduPackUInt32, &param->sduId, mBuf);
1835    CMCHKUNPK(cmUnpkLteRlcId, &param->rlcId, mBuf);
1836
1837    return ROK;
1838 }
1839
1840 \f
1841 #ifdef ANSI
1842 S16 cmUnpkKwuDatAckInd
1843 (
1844 KwuDatAckInd func,
1845 Pst *pst,
1846 Buffer *mBuf
1847 )
1848 #else
1849 S16 cmUnpkKwuDatAckInd(func, pst, mBuf)
1850 KwuDatAckInd func;
1851 Pst *pst;
1852 Buffer *mBuf;
1853 #endif
1854 {
1855     S16 ret1;
1856     SuId          suId = 0;
1857     KwuDatAckInfo *datInd = NULLP;
1858     
1859
1860     if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&datInd,\
1861                 sizeof(KwuDatAckInfo),SS_SHARABLE_MEMORY)) != ROK)
1862     {
1863 #if (ERRCLASS & ERRCLS_ADD_RES)
1864        if(ret1 != ROK)
1865        {
1866           SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
1867                 __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
1868                 (ErrVal)ERRKWU, (ErrVal)0, "SGetMsg() failed");
1869        }
1870 #endif /*  ERRCLASS & ERRCLS_ADD_RES  */
1871        return (ret1);
1872     }
1873
1874     memset(datInd, 0, sizeof(KwuDatAckInfo));
1875
1876     CMCHKUNPK(SUnpkS16, &(suId), mBuf);
1877     ret1 = cmUnpkKwuDatAckInfo( (datInd), mBuf);
1878 #if(ERRCLASS & ERRCLS_DEBUG)
1879     if(ret1 != ROK)
1880     {
1881        SPutMsg(mBuf);
1882        SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId,
1883              __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
1884              (ErrVal)ERRKWU, (ErrVal)ret1, "Unpacking failure");
1885        return ( ret1 );
1886     }
1887 #endif /* ERRCLASS & ERRCLS_DEBUG */
1888
1889     return ((*func)(pst, suId, datInd));
1890 } /* cmUnpkKwuDatAckInd */
1891 #endif /* LTE_L2_MEAS */
1892 #endif /* LCKWU */
1893
1894 /**********************************************************************
1895          End of file
1896  **********************************************************************/