5a2653bf0494211effccf69c4aa6b213bce30c3d
[o-du/l2.git] / src / cm / rgu.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18
19 /************************************************************************
20  
21      Name:     LTE-MAC layer
22   
23      Type:     C source file
24   
25      Desc:     C source code for packing/unpacking of RGU interface
26                primitives.
27   
28      File:     rgu.c 
29   
30 **********************************************************************/
31
32 /** @file rgu.c
33 @brief This file contains the packing/unpacking code for the RGU interface 
34        primitives.
35 */
36
37 /* header include files (.h) */
38 #include "common_def.h"
39 #include "rgu.h"           /* RGU Interface defines */
40
41 /* header/extern include files (.x) */
42 #include "rgu.x"           /* RGU Interface includes */
43
44 #ifdef SS_RBUF
45 #include "ss_rbuf.h"
46 #include "ss_rbuf.x"
47 #endif
48
49 #ifdef LCRGU
50
51 \f
52 /**
53 * @brief Request from RLC to MAC to bind the interface saps
54 *
55 * @details
56 *
57 *     Function : cmPkRguBndReq
58 *
59 *  @param[in]   Pst*  pst
60 *  @param[in]   SuId  suId
61 *  @param[in]   SpId  spId
62 *  @return   S16
63 *      -# ROK
64 **/
65 S16 cmPkRguBndReq
66 (
67 Pst* pst,
68 SuId suId,
69 SpId spId
70 )
71 {
72    Buffer *mBuf = NULLP;
73
74    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
75 #if (ERRCLASS & ERRCLS_ADD_RES)      
76       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
77           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
78           (ErrVal)ERGU001, (ErrVal)0, "Packing failed");
79 #endif      
80       return RFAILED;
81    }
82    if (SPkS16(spId, mBuf) != ROK) {
83 #if (ERRCLASS & ERRCLS_ADD_RES)      
84       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
85           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
86           (ErrVal)ERGU002, (ErrVal)0, "Packing failed");
87 #endif      
88       SPutMsg(mBuf);
89       return RFAILED;
90    }
91    if (SPkS16(suId, mBuf) != ROK) {
92 #if (ERRCLASS & ERRCLS_ADD_RES)      
93       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
94           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
95           (ErrVal)ERGU003, (ErrVal)0, "Packing failed");
96 #endif      
97       SPutMsg(mBuf);
98       return RFAILED;
99    }
100    pst->event = (Event) EVTRGUBNDREQ;
101    return (SPstTsk(pst,mBuf));
102 }
103
104 \f
105 /**
106 * @brief Request from RLC to MAC to bind the interface saps
107 *
108 * @details
109 *
110 *     Function : cmUnpkRguBndReq
111 *
112 *  @param[in]   Pst*  pst
113 *  @param[in]   SuId  suId
114 *  @param[in]   SpId  spId
115 *  @return   S16
116 *      -# ROK
117 **/
118 S16 cmUnpkRguBndReq
119 (
120 RguBndReq func,
121 Pst *pst,
122 Buffer *mBuf
123 )
124 {
125    SuId suId;
126    SpId spId;
127
128    if (SUnpkS16(&suId, mBuf) != ROK) {
129 #if (ERRCLASS & ERRCLS_ADD_RES)      
130       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
131           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
132           (ErrVal)ERGU004, (ErrVal)0, "UnPacking failed");
133 #endif      
134       SPutMsg(mBuf);
135       return RFAILED;
136    }
137    if (SUnpkS16(&spId, mBuf) != ROK) {
138 #if (ERRCLASS & ERRCLS_ADD_RES)      
139       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
140           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
141           (ErrVal)ERGU005, (ErrVal)0, "UnPacking failed");
142 #endif      
143       SPutMsg(mBuf);
144       return RFAILED;
145    }
146    SPutMsg(mBuf);
147    return ((*func)(pst, suId, spId));
148 }
149
150 \f
151 /**
152 * @brief Request from RLC to MAC to Unbind the interface saps
153 *
154 * @details
155 *
156 *     Function : cmPkRguUbndReq
157 *
158 *  @param[in]   Pst*  pst
159 *  @param[in]   SpId  spId
160 *  @param[in]   Reason  reason
161 *  @return   S16
162 *      -# ROK
163 **/
164 S16 cmPkRguUbndReq
165 (
166 Pst* pst,
167 SpId spId,
168 Reason reason
169 )
170 {
171    Buffer *mBuf = NULLP;
172
173    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
174 #if (ERRCLASS & ERRCLS_ADD_RES)      
175       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
176           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
177           (ErrVal)ERGU006, (ErrVal)0, "Packing failed");
178 #endif      
179       return RFAILED;
180    }
181    if (SPkS16(reason, mBuf) != ROK) {
182 #if (ERRCLASS & ERRCLS_ADD_RES)      
183       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
184           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
185           (ErrVal)ERGU007, (ErrVal)0, "Packing failed");
186 #endif      
187       SPutMsg(mBuf);
188       return RFAILED;
189    }
190    if (SPkS16(spId, mBuf) != ROK) {
191 #if (ERRCLASS & ERRCLS_ADD_RES)      
192       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
193           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
194           (ErrVal)ERGU008, (ErrVal)0, "Packing failed");
195 #endif      
196       SPutMsg(mBuf);
197       return RFAILED;
198    }
199    pst->event = (Event) EVTRGUUBNDREQ;
200    return (SPstTsk(pst,mBuf));
201 }
202
203 \f
204 /**
205 * @brief Request from RLC to MAC to Unbind the interface saps
206 *
207 * @details
208 *
209 *     Function : cmUnpkRguUbndReq
210 *
211 *  @param[in]   Pst*  pst
212 *  @param[in]   SpId  spId
213 *  @param[in]   Reason  reason
214 *  @return   S16
215 *      -# ROK
216 **/
217 S16 cmUnpkRguUbndReq
218 (
219 RguUbndReq func,
220 Pst *pst,
221 Buffer *mBuf
222 )
223 {
224    SpId spId;
225    Reason reason;
226    
227
228    if (SUnpkS16(&spId, mBuf) != ROK) {
229 #if (ERRCLASS & ERRCLS_ADD_RES)      
230       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
231           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
232           (ErrVal)ERGU009, (ErrVal)0, "UnPacking failed");
233 #endif      
234       SPutMsg(mBuf);
235       return RFAILED;
236    }
237    if (SUnpkS16(&reason, mBuf) != ROK) {
238 #if (ERRCLASS & ERRCLS_ADD_RES)      
239       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
240           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
241           (ErrVal)ERGU010, (ErrVal)0, "UnPacking failed");
242 #endif      
243       SPutMsg(mBuf);
244       return RFAILED;
245    }
246    SPutMsg(mBuf);
247    return ((*func)(pst, spId, reason));
248 }
249
250 \f
251 /**
252 * @brief Confirmation from MAC to RLC for the bind/Unbind 
253  * request for the interface saps
254 *
255 * @details
256 *
257 *     Function : cmPkRguBndCfm
258 *
259 *  @param[in]   Pst*  pst
260 *  @param[in]   SuId  suId
261 *  @param[in]   uint8_t  status
262 *  @return   S16
263 *      -# ROK
264 **/
265 S16 cmPkRguBndCfm
266 (
267 Pst* pst,
268 SuId suId,
269 uint8_t status
270 )
271 {
272    Buffer *mBuf = NULLP;
273
274    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
275 #if (ERRCLASS & ERRCLS_ADD_RES)      
276       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
277           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
278           (ErrVal)ERGU011, (ErrVal)0, "Packing failed");
279 #endif      
280       return RFAILED;
281    }
282    if (oduUnpackUInt8(status, mBuf) != ROK) {
283 #if (ERRCLASS & ERRCLS_ADD_RES)      
284       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
285           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
286           (ErrVal)ERGU012, (ErrVal)0, "Packing failed");
287 #endif      
288       SPutMsg(mBuf);
289       return RFAILED;
290    }
291    if (SPkS16(suId, mBuf) != ROK) {
292 #if (ERRCLASS & ERRCLS_ADD_RES)      
293       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
294           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
295           (ErrVal)ERGU013, (ErrVal)0, "Packing failed");
296 #endif      
297       SPutMsg(mBuf);
298       return RFAILED;
299    }
300    pst->event = (Event) EVTRGUBNDCFM;
301    return (SPstTsk(pst,mBuf));
302 }
303
304 \f
305 /**
306 * @brief Confirmation from MAC to RLC for the bind/Unbind 
307  * request for the interface saps
308 *
309 * @details
310 *
311 *     Function : cmUnpkRguBndCfm
312 *
313 *  @param[in]   Pst*  pst
314 *  @param[in]   SuId  suId
315 *  @param[in]   uint8_t  status
316 *  @return   S16
317 *      -# ROK
318 **/
319 S16 cmUnpkRguBndCfm
320 (
321 RguBndCfm func,
322 Pst *pst,
323 Buffer *mBuf
324 )
325 {
326    SuId suId;
327    uint8_t status;
328
329    if (SUnpkS16(&suId, mBuf) != ROK) {
330 #if (ERRCLASS & ERRCLS_ADD_RES)      
331       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
332           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
333           (ErrVal)ERGU014, (ErrVal)0, "UnPacking failed");
334 #endif      
335       SPutMsg(mBuf);
336       return RFAILED;
337    }
338    if (oduPackUInt8(&status, mBuf) != ROK) {
339 #if (ERRCLASS & ERRCLS_ADD_RES)      
340       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
341           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
342           (ErrVal)ERGU015, (ErrVal)0, "UnPacking failed");
343 #endif      
344       SPutMsg(mBuf);
345       return RFAILED;
346    }
347    SPutMsg(mBuf);
348    return ((*func)(pst, suId, status));
349 }
350
351 /*rgu_c_001.main_5 - ADD - L2M & R9 Support */
352 #ifdef LTE_L2_MEAS
353
354 /***********************************************************
355 *
356 *     Func :cmPkRguL2MUlThrpMeasReqInfo 
357 *
358 *
359 * Status Response from RLC to MAC on UL dedicated logical channel for Uplink
360 * Scheduled throughput measurement
361 *
362 *
363 *     Ret  : S16
364 *
365 *     Notes:
366 *
367 *     File  : 
368 *
369 **********************************************************/
370 S16 cmPkRguL2MUlThrpMeasReqInfo 
371 (
372 RguL2MUlThrpMeasReqInfo* param,
373 Buffer *mBuf
374 )
375 {
376    S32 loop;
377
378    CMCHKPK(oduUnpackUInt8, param->enbMeas, mBuf);
379    for (loop=param->numLcId-1; loop >= 0; loop--)
380    {
381       CMCHKPK(oduUnpackUInt8, param->lcId[loop], mBuf);
382    }
383    CMCHKPK(cmPkLteLcId, param->numLcId, mBuf);
384    CMCHKPK(cmPkLteRnti, param->rnti, mBuf);
385    CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
386    return ROK;
387 }
388
389
390 \f
391 /***********************************************************
392 *
393 *     Func :cmUnpkRguL2MUlThrpMeasReqInfo 
394 *
395 *
396 * Status Response from RLC to MAC on UL dedicated logical channel for Uplink
397 * Scheduled throughput measurement
398 *
399 *
400 *     Ret  : S16
401 *
402 *     Notes:
403 *
404 *     File  : 
405 *
406 **********************************************************/
407 S16 cmUnpkRguL2MUlThrpMeasReqInfo 
408 (
409 RguL2MUlThrpMeasReqInfo *param,
410 Buffer *mBuf
411 )
412 {
413    uint8_t loop;
414
415    CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
416    CMCHKUNPK(cmUnpkLteRnti, &param->rnti, mBuf);
417    CMCHKUNPK(cmUnpkLteLcId, &param->numLcId, mBuf);
418    for (loop=0; loop<param->numLcId; loop++)
419    {
420       CMCHKUNPK(oduPackUInt8, &param->lcId[loop], mBuf);
421    }
422    CMCHKUNPK(oduPackUInt8, &param->enbMeas, mBuf);
423    return ROK;
424 }
425
426 /**
427 * @brief Primitive invoked from RLC to MAC to 
428 * inform the On/Off status for Scheduled UL throughput 
429 * measurment for dedicated channels
430 *
431 * @details
432 *
433 *     Function :cmPkRguL2MUlThrpMeasReq 
434 *
435 *  @param[in]   Pst*  pst
436 *  @param[in]   SpId  spId
437 *  @param[in]   RguL2MUlThrpMeasReqInfo*  measReq
438 *  @return   S16
439 *      -# ROK
440 **/
441 S16 cmPkRguL2MUlThrpMeasReq 
442 (
443 Pst* pst,
444 SpId spId,
445 RguL2MUlThrpMeasReqInfo* measReq
446 )
447 {
448    Buffer *mBuf = NULLP;
449
450    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
451 #if (ERRCLASS & ERRCLS_ADD_RES)      
452       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
453           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
454           (ErrVal)ERGU049, (ErrVal)0, "Packing failed");
455 #endif      
456       SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)measReq, sizeof(RguL2MUlThrpMeasReqInfo));
457       return RFAILED;
458    }
459    if (pst->selector == ODU_SELECTOR_LWLC)
460    {
461       CMCHKPK(oduPackPointer,(PTR) measReq, mBuf);
462    }
463    else
464    {
465       if (cmPkRguL2MUlThrpMeasReqInfo(measReq, mBuf) != ROK) {
466 #if (ERRCLASS & ERRCLS_ADD_RES)      
467          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
468              __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
469              (ErrVal)ERGU050, (ErrVal)0, "Packing failed");
470 #endif      
471          SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)measReq, 
472                                     sizeof(RguL2MUlThrpMeasReqInfo));
473          SPutMsg(mBuf);
474          return RFAILED;
475       }
476       if (SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)measReq, 
477                            sizeof(RguL2MUlThrpMeasReqInfo)) != ROK) {
478 #if (ERRCLASS & ERRCLS_ADD_RES)      
479          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
480             __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
481              (ErrVal)ERGU052, (ErrVal)0, "Packing failed");
482 #endif      
483          SPutMsg(mBuf);
484          return RFAILED;
485       }
486       measReq = NULLP;
487    }
488
489    if (SPkS16(spId, mBuf) != ROK) {
490 #if (ERRCLASS & ERRCLS_ADD_RES)      
491       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
492           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
493           (ErrVal)ERGU051, (ErrVal)0, "Packing failed");
494 #endif      
495       if (measReq != NULLP)
496       {
497          SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)measReq,
498                              sizeof(RguL2MUlThrpMeasReqInfo));
499       }
500       SPutMsg(mBuf);
501       return RFAILED;
502    }
503
504    pst->event = (Event) EVTRGUL2MULTHRPMEASREQ;
505    return (SPstTsk(pst,mBuf));
506 }
507
508 \f
509 /**
510 * @brief Primitive invoked from RLC to MAC to 
511 * inform the On/Off status for Scheduled UL throughput 
512 * measurment for dedicated channels
513 *
514 * @details
515 *
516 *     Function :cmUnpkRguL2MUlThrpMeasReq 
517 *
518 *  @param[in]   Pst*  pst
519 *  @param[in]   SpId  spId
520 *  @param[in]   RguL2MUlThrpMeasReqInfo  * measReq 
521 *  @return   S16
522 *      -# ROK
523 **/
524 S16 cmUnpkRguL2MUlThrpMeasReq 
525 (
526 RguL2MUlThrpMeasReq func,
527 Pst *pst,
528 Buffer *mBuf
529 )
530 {
531    SpId spId;
532    RguL2MUlThrpMeasReqInfo* measReq;
533    
534
535    if (SUnpkS16(&spId, mBuf) != ROK) {
536 #if (ERRCLASS & ERRCLS_ADD_RES)      
537       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
538           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
539           (ErrVal)ERGU053, (ErrVal)0, "UnPacking failed");
540 #endif      
541       SPutMsg(mBuf);
542       return RFAILED;
543    }
544    if (pst->selector == ODU_SELECTOR_LWLC)
545    {
546       CMCHKUNPK(oduUnpackPointer,(PTR *) &measReq, mBuf);
547    }
548    else 
549    {
550       if ((SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data **)&measReq,
551                               sizeof(RguL2MUlThrpMeasReqInfo))) != ROK) {
552 #if (ERRCLASS & ERRCLS_ADD_RES)      
553          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
554              __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
555              (ErrVal)ERGU054, (ErrVal)0, "UnPacking failed");
556 #endif      
557          SPutMsg(mBuf);
558          return RFAILED;
559       }
560       if (cmUnpkRguL2MUlThrpMeasReqInfo(measReq, mBuf) != ROK) {
561 #if (ERRCLASS & ERRCLS_ADD_RES)      
562          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
563              __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
564              (ErrVal)ERGU055, (ErrVal)0, "UnPacking failed");
565 #endif      
566          SPutMsg(mBuf);
567          SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)measReq, 
568                                 sizeof(RguL2MUlThrpMeasReqInfo));
569          return RFAILED;
570       }
571    }
572    SPutMsg(mBuf);
573    return ((*func)(pst, spId, measReq));
574 }
575
576 #endif
577
578
579    /*rgu_c_001.main_5 - ADD - L2M Support */
580 #ifdef LTE_L2_MEAS
581 \f
582 /**
583 * @brief Harq Status Indication from MAC to RLC  
584 *
585 * @details
586 *
587 *     Function : cmPkRguHqStaInd
588 *
589 *  @param[in]   Pst*  pst
590 *  @param[in]   SuId  suId
591 *  @param[in]   RguHarqStatusInd  *harqStatusInd
592 *  @return   S16
593 *      -# ROK
594 **/
595 S16 cmPkRguHqStaInd
596 (
597 Pst* pst,
598 SuId suId,
599 RguHarqStatusInd  *harqStatusInd
600 )
601 {
602
603    Buffer   *mBuf;
604    uint8_t  idx;
605    RguHarqStatusInd *harqStaInd = NULL;
606
607 #ifdef XEON_SPECIFIC_CHANGES
608    if (SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data **)&harqStaInd, sizeof(RguHarqStatusInd)) != ROK)
609 #else      
610    if ((SGetStaticBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, 
611                (Data **)&harqStaInd, sizeof(RguHarqStatusInd),0)) != ROK)
612 #endif      
613    {
614 #if (ERRCLASS & ERRCLS_ADD_RES)      
615       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
616             __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
617             (ErrVal)ERGU070, (ErrVal)0, "Packing failed");
618 #endif      
619       return RFAILED;
620    }
621
622    memcpy(harqStaInd, harqStatusInd, sizeof(RguHarqStatusInd));
623
624    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
625 #if (ERRCLASS & ERRCLS_ADD_RES)      
626       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
627             __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
628             (ErrVal)ERGU070, (ErrVal)0, "Packing failed");
629 #endif
630 #ifdef XEON_SPECIFIC_CHANGES
631       SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)harqStaInd, sizeof(RguHarqStatusInd));
632 #else      
633       SPutStaticBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)harqStaInd, sizeof(RguHarqStatusInd), 0);
634 #endif      
635       return RFAILED;
636    }
637
638    if (pst->selector == ODU_SELECTOR_LWLC)
639    {
640       CMCHKPK(oduPackPointer,(PTR) harqStaInd, mBuf); 
641    }
642    else
643    {
644       for(idx = 0; idx < harqStaInd->numTbs; idx++)
645       {
646          CMCHKPK(oduUnpackUInt16, harqStaInd->status[idx], mBuf);
647       }
648       for(idx = 0; idx < harqStaInd->numTbs; idx++)
649       {
650          CMCHKPK(oduUnpackUInt32, harqStaInd->tbId[idx], mBuf);
651       }
652       CMCHKPK(oduUnpackUInt8, harqStaInd->numTbs, mBuf);
653       CMCHKPK(cmPkLteRnti, harqStaInd->ueId, mBuf);
654       CMCHKPK(cmPkLteCellId, harqStaInd->cellId, mBuf);
655    }
656    if (SPkS16(suId, mBuf) != ROK) {
657 #if (ERRCLASS & ERRCLS_ADD_RES)      
658       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
659           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
660           (ErrVal)ERGU071, (ErrVal)0, "Packing failed");
661 #endif
662 #ifdef XEON_SPECIFIC_CHANGES
663       SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)harqStaInd,
664               sizeof(RguHarqStatusInd));
665 #else      
666       SPutStaticBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)harqStaInd, sizeof(RguHarqStatusInd), 0);
667 #endif      
668       SPutMsg(mBuf);
669       return RFAILED;
670    }
671 #ifdef XEON_SPECIFIC_CHANGES
672    if (SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)harqStaInd,
673             sizeof(RguHarqStatusInd)) != ROK) {
674 #else   
675    if (pst->selector != ODU_SELECTOR_LWLC)
676    {
677       if(SPutStaticBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)harqStaInd, 
678                sizeof(RguHarqStatusInd), 0) != ROK)
679       {
680 #endif         
681 #if (ERRCLASS & ERRCLS_ADD_RES)      
682          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
683                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
684                (ErrVal)ERGU072, (ErrVal)0, "Packing failed");
685 #endif      
686          SPutMsg(mBuf);
687          return RFAILED;
688       }
689 #ifndef XEON_SPECIFIC_CHANGES      
690    }
691 #endif   
692
693    pst->event = (Event) EVTRGUHQSTAIND;
694    return (SPstTsk(pst,mBuf));
695 }
696 \f
697
698 /**
699 * @brief Harq Status Indication from MAC to RLC  
700 *
701 * @details
702 *
703 *     Function : cmUnpkRguHqStaInd
704 *
705 *  @param[in]  RguHqStaInd   func
706 *  @param[in]  Pst           *pst
707 *  @param[in]  Buffer        *mBuf
708 *  @return   S16
709 *      -# ROK
710 **/
711 S16 cmUnpkRguHqStaInd
712 (
713 RguHqStaInd  func,
714 Pst *pst,
715 Buffer *mBuf
716 )
717 {
718    RguHarqStatusInd    *hqStaInd;  
719    SuId    suId;
720    uint8_t idx;
721
722    if (SUnpkS16(&suId, mBuf) != ROK) {
723 #if (ERRCLASS & ERRCLS_ADD_RES)      
724       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
725           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
726           (ErrVal)ERGU073, (ErrVal)0, "UnPacking failed");
727 #endif      
728       SPutMsg(mBuf);
729       return RFAILED;
730    }
731 #ifdef XEON_SPECIFIC_CHANGES
732    if ((SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data **)&hqStaInd, 
733         sizeof(RguHarqStatusInd))) != ROK) {
734 #else   
735    if (pst->selector == ODU_SELECTOR_LWLC)
736    {
737       CMCHKUNPK(oduUnpackPointer,(PTR *) &hqStaInd, mBuf);
738    }  
739    else
740    {   
741       if ((SGetStaticBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, 
742                   (Data **)&hqStaInd, sizeof(RguHarqStatusInd),0)) != ROK)
743       {
744 #endif         
745 #if (ERRCLASS & ERRCLS_ADD_RES)      
746          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
747                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
748                (ErrVal)ERGU074, (ErrVal)0, "UnPacking failed");
749 #endif      
750          SPutMsg(mBuf);
751          return RFAILED;
752       }
753       CMCHKUNPK(cmUnpkLteCellId, &hqStaInd->cellId, mBuf);
754       CMCHKUNPK(cmUnpkLteRnti, &hqStaInd->ueId, mBuf);
755       CMCHKUNPK(oduPackUInt8, &hqStaInd->numTbs, mBuf);
756       for(idx = hqStaInd->numTbs; idx > 0; idx--)
757       {
758          CMCHKUNPK(oduPackUInt32, &hqStaInd->tbId[idx - 1], mBuf);
759       }
760       for(idx = hqStaInd->numTbs; idx > 0; idx--)
761       {
762          CMCHKUNPK(oduPackUInt16, &hqStaInd->status[idx - 1], mBuf);
763       }
764 #ifndef XEON_SPECIFIC_CHANGES      
765    }
766 #endif   
767    SPutMsg(mBuf);
768    (*func)(pst, suId, hqStaInd);
769 #ifdef XEON_SPECIFIC_CHANGES
770    SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)hqStaInd, sizeof(RguHarqStatusInd));
771 #else   
772    SPutStaticBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)hqStaInd, sizeof(RguHarqStatusInd), 0);
773 #endif   
774    return ROK;
775 }
776 #endif /* LTE_L2_MEAS */
777
778 S16 cmPkRguLcFlowCntrlInfo
779 (
780 RguLcFlowCntrlInfo *param,
781 Buffer             *mBuf
782 )
783 {
784   CMCHKPK(oduUnpackUInt32, param->maxBo4FlowCtrl, mBuf);
785   CMCHKPK(oduUnpackUInt32, param->pktAdmitCnt, mBuf);
786   CMCHKPK(cmPkLteLcId, param->lcId, mBuf);
787
788   return ROK;
789 }
790
791 S16 cmPkRguUeFlowCntrlInfo
792 (
793 RguUeFlowCntrlInfo *param,
794 Buffer             *mBuf
795 )
796 {
797   uint32_t idx;
798
799
800   for(idx=(param->numLcs - 1); idx >= 0; idx--)
801   {
802     cmPkRguLcFlowCntrlInfo(&param->lcInfo[idx],mBuf);
803   }
804   CMCHKPK(oduUnpackUInt32, param->numLcs, mBuf);
805   CMCHKPK(cmPkLteRnti, param->ueId, mBuf);
806   return ROK;
807 }
808
809 S16 cmPkRguFlowCntrlInfo
810 (
811 RguFlowCntrlInd *param, 
812 Buffer          *mBuf
813 )
814 {
815   uint32_t idx;
816
817   for (idx=(param->numUes - 1); idx >= 0; idx--)
818   {
819     cmPkRguUeFlowCntrlInfo(&param->ueFlowCntrlInfo[idx],mBuf);
820   }
821   CMCHKPK(oduUnpackUInt32, param->numUes, mBuf);
822   CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
823   return ROK;
824 }
825 \f
826 /**
827 * @brief Flow Cntrl Indication from MAC to RLC  
828  * Informs RLC of the LCs on which flow control
829  * to be performed.
830 *
831 * @details
832 *
833 *     Function : cmPkRguFlowCntrlInd
834 *
835 *  @param[in]   Pst*  pst
836 *  @param[in]   SuId  suId
837 *  @param[in]   RguFlowCntrlInd *staInd
838 *  @return   S16
839 *      -# ROK
840 **/
841 S16 cmPkRguFlowCntrlInd
842 (
843 Pst* pst,
844 SuId suId,
845 RguFlowCntrlInd  *flowCntrlInd
846 )
847 {
848    Buffer *mBuf = NULLP;
849
850    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
851 #if (ERRCLASS & ERRCLS_ADD_RES)      
852       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
853           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
854           (ErrVal)ERGU076, (ErrVal)0, "Packing failed");
855 #endif      
856       return RFAILED;
857    }
858    if (pst->selector == ODU_SELECTOR_LWLC)
859    {
860       CMCHKPK(oduPackPointer,(PTR) flowCntrlInd, mBuf);
861    }
862    else
863    {
864       if (cmPkRguFlowCntrlInfo(flowCntrlInd, mBuf) != ROK) {
865 #if (ERRCLASS & ERRCLS_ADD_RES)      
866            SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
867                __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
868                (ErrVal)ERGU077, (ErrVal)0, "Packing failed");
869 #endif      
870          SPutMsg(mBuf);
871          return RFAILED;
872       } 
873    }
874    if (SPkS16(suId, mBuf) != ROK) {
875 #if (ERRCLASS & ERRCLS_ADD_RES)      
876       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
877           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
878           (ErrVal)ERGU078, (ErrVal)0, "Packing failed");
879 #endif      
880       SPutMsg(mBuf);
881       return RFAILED;
882    }
883    
884    pst->event = (Event) EVTRGUFLOWCNTRLIND;
885    return (SPstTsk(pst,mBuf));
886 }
887
888 S16 cmUnpkRguLcFlowCntrlInfo
889 (
890 RguLcFlowCntrlInfo *param,
891 Buffer           *mBuf
892 )
893 {
894
895   CMCHKUNPK(cmUnpkLteLcId, &param->lcId, mBuf);
896   CMCHKUNPK(oduPackUInt32, &param->pktAdmitCnt, mBuf);
897   CMCHKUNPK(oduPackUInt32, &param->maxBo4FlowCtrl, mBuf);
898   
899   return ROK;
900 }
901 S16 cmUnpkRguUeFlowCntrlInfo
902 (
903 RguUeFlowCntrlInfo *param,
904 Buffer           *mBuf
905 )
906 {
907   uint32_t idx;
908   CMCHKUNPK(cmUnpkLteRnti, &param->ueId, mBuf);
909   CMCHKUNPK(oduPackUInt32, &param->numLcs, mBuf);
910   for(idx=0; idx < param->numLcs; idx++)
911   {
912     cmUnpkRguLcFlowCntrlInfo(&param->lcInfo[idx],mBuf);
913   }
914   return ROK;
915 }
916
917 S16 cmUnpkRguFlowCntrlInfo
918 (
919 RguFlowCntrlInd *param, 
920 Buffer           *mBuf
921 )
922 {
923   uint32_t idx; 
924   
925
926   CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
927   CMCHKUNPK(oduPackUInt32, &param->numUes, mBuf);
928   for (idx=0; idx < param->numUes; idx++)
929   {
930     cmUnpkRguUeFlowCntrlInfo(&param->ueFlowCntrlInfo[idx],mBuf);
931   }
932   return ROK;
933 }
934
935 /**
936 * @brief Flow control indication from MAC to RLC  
937 * Informs RLC of the LCs on which flow control to  
938 * be started
939 *
940 * @details
941 *
942 *     Function : cmUnpkRguFlowCntrlInd
943 *
944 *  @param[in]   RguFlowCntrlInd func
945 *  @param[in]   Pst    *pst
946 *  @param[in]   Buffer *mBuf
947 *  @return   S16
948 *      -# ROK
949 **/
950 S16 cmUnpkRguFlowCntrlInd
951 (
952 RguFlowCntrlIndInfo func,
953 Pst *pst,
954 Buffer *mBuf
955 )
956 {
957    SuId suId;
958    RguFlowCntrlInd *flowCntrlInd;
959
960    if (SUnpkS16(&suId, mBuf) != ROK) {
961 #if (ERRCLASS & ERRCLS_ADD_RES)      
962       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
963           __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
964           (ErrVal)ERGU080, (ErrVal)0, "UnPacking failed");
965 #endif      
966       SPutMsg(mBuf);
967       return RFAILED;
968    }
969    if (pst->selector == ODU_SELECTOR_LWLC)
970    {
971       CMCHKUNPK(oduUnpackPointer,(PTR *) &flowCntrlInd, mBuf);
972    }
973    else 
974    {
975       if ((SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data **)&flowCntrlInd, sizeof(RguFlowCntrlInd))) != ROK) {
976 #if (ERRCLASS & ERRCLS_ADD_RES)      
977          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
978          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
979          (ErrVal)ERGU081, (ErrVal)0, "UnPacking failed");
980 #endif      
981          SPutMsg(mBuf);
982          return RFAILED;
983       }
984       if (cmUnpkRguFlowCntrlInfo(flowCntrlInd, mBuf) != ROK) {
985 #if (ERRCLASS & ERRCLS_ADD_RES)      
986          SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
987              __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
988              (ErrVal)ERGU082, (ErrVal)0, "UnPacking failed");
989 #endif      
990          SPutMsg(mBuf);
991          SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)flowCntrlInd, sizeof(RguFlowCntrlInd));
992          return RFAILED;
993       }
994    }
995    SPutMsg(mBuf);
996    return ((*func)(pst, suId, flowCntrlInd));
997 }
998
999 /***********************************************************
1000 *
1001 *     Func : cmPkRguPduInfo
1002 *
1003 *
1004 *     Desc : RguPduInfo
1005  * PDU information given on a logical channel
1006 *
1007 *
1008 *     Ret  : S16
1009 *
1010 *     Notes:
1011 *
1012 *     File  : 
1013 *
1014 **********************************************************/
1015 S16 cmPkRguPduInfo
1016 (
1017 RguPduInfo *param,
1018 Buffer *mBuf
1019 )
1020 {
1021    S32 i;
1022
1023    for (i=param->numPdu-1; i >= 0; i--) {
1024      /* rgu_c_001.main_3: ccpu00111328: S16 is renamed as MsgLen */
1025       MsgLen msgLen = 0;
1026       if (SFndLenMsg(param->mBuf[i], &msgLen) != ROK)
1027          return RFAILED;
1028       if (SCatMsg(mBuf, param->mBuf[i], M1M2) != ROK)
1029          return RFAILED;
1030       SPutMsg(param->mBuf[i]);
1031       CMCHKPK(cmPkMsgLen, msgLen, mBuf);
1032    }
1033    CMCHKPK(oduUnpackUInt8, param->numPdu, mBuf);
1034    return ROK;
1035 }
1036
1037
1038 \f
1039 /***********************************************************
1040 *
1041 *     Func : cmUnpkRguPduInfo
1042 *
1043 *
1044 *     Desc : RguPduInfo
1045  * PDU information given on a logical channel
1046 *
1047 *
1048 *     Ret  : S16
1049 *
1050 *     Notes:
1051 *
1052 *     File  : 
1053 *
1054 **********************************************************/
1055 S16 cmUnpkRguPduInfo
1056 (
1057 RguPduInfo *param,
1058 Buffer *mBuf
1059 )
1060 {
1061    S32 i;
1062
1063
1064    CMCHKUNPK(oduPackUInt8, &param->numPdu, mBuf);
1065    for (i=0; i<param->numPdu; i++) {
1066       MsgLen msgLen, totalMsgLen;
1067       CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf);
1068       if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
1069          return RFAILED;
1070       if (SSegMsg(mBuf, totalMsgLen-msgLen, &param->mBuf[i]) != ROK)
1071          return RFAILED;
1072    }
1073    return ROK;
1074 }
1075
1076
1077 \f
1078 /***********************************************************
1079 *
1080 *     Func : cmPkRguDBoReport
1081 *
1082 *
1083 *     Desc : RguDBoReport
1084  * Buffer Occupancy Report for dedicated logical channel
1085 *
1086 *
1087 *     Ret  : S16
1088 *
1089 *     Notes:
1090 *
1091 *     File  : 
1092 *
1093 **********************************************************/
1094 S16 cmPkRguDBoReport
1095 (
1096 RguDBoReport *param,
1097 Buffer *mBuf
1098 )
1099 {
1100
1101    CMCHKPK(oduUnpackUInt32, param->oldestSduArrTime, mBuf);
1102    CMCHKPK(oduUnpackUInt32, param->staPduBo, mBuf);
1103 #ifdef CCPU_OPT
1104    CMCHKPK(oduUnpackUInt8, param->staPduPrsnt, mBuf);
1105    CMCHKPK(oduUnpackUInt16, param->estRlcHdrSz, mBuf);
1106 #endif
1107    CMCHKPK(SPkS32, param->bo, mBuf);
1108    return ROK;
1109 }
1110
1111
1112 \f
1113 /***********************************************************
1114 *
1115 *     Func : cmUnpkRguDBoReport
1116 *
1117 *
1118 *     Desc : RguDBoReport
1119  * Buffer Occupancy Report for dedicated logical channel
1120 *
1121 *
1122 *     Ret  : S16
1123 *
1124 *     Notes:
1125 *
1126 *     File  : 
1127 *
1128 **********************************************************/
1129 S16 cmUnpkRguDBoReport
1130 (
1131 RguDBoReport *param,
1132 Buffer *mBuf
1133 )
1134 {
1135
1136
1137    CMCHKUNPK(SUnpkS32, &param->bo, mBuf);
1138 #ifdef CCPU_OPT
1139    CMCHKUNPK(oduPackUInt16, &param->estRlcHdrSz, mBuf);
1140    CMCHKUNPK(oduPackUInt8, &param->staPduPrsnt, mBuf);
1141 #endif
1142    
1143    CMCHKUNPK(oduPackUInt32, &param->staPduBo, mBuf);
1144    CMCHKUNPK(oduPackUInt32, &param->oldestSduArrTime, mBuf);
1145    return ROK;
1146 }
1147
1148 \f
1149 /***********************************************************
1150 *
1151 *     Func : cmPkRguCDatReqInfo
1152 *
1153 *
1154 *     Desc : RguCDatReqInfo
1155  * DatReq from RLC to MAC for Common Channels(BCCH, PCCH and CCCH)
1156 *
1157 *
1158 *     Ret  : S16
1159 *
1160 *     Notes:
1161 *
1162 *     File  : 
1163 *
1164 **********************************************************/
1165 S16 cmPkRguCDatReqInfo
1166 (
1167 RguCDatReqInfo *param,
1168 Buffer *mBuf
1169 )
1170 {
1171    MsgLen msgLen;
1172
1173    if (param->pdu != NULLP)
1174    {
1175       if (SFndLenMsg(param->pdu, &msgLen) != ROK)
1176          return RFAILED;
1177       if (SCatMsg(mBuf, param->pdu, M1M2) != ROK)
1178          return RFAILED;
1179       SPutMsg(param->pdu);
1180       CMCHKPK(cmPkMsgLen, msgLen, mBuf);
1181    }
1182    switch(param->lcType) {
1183       case CM_LTE_LCH_CCCH:
1184          CMCHKPK(cmPkLteRnti, param->u.rnti, mBuf);
1185          break;
1186       case CM_LTE_LCH_BCCH:
1187       case CM_LTE_LCH_PCCH:
1188          CMCHKPK(cmPkLteTimingInfo, &param->u.timeToTx, mBuf);
1189 #ifdef EMTC_ENABLE
1190         CMCHKPK(oduUnpackUInt8,param->pnb,mBuf);
1191 #endif
1192          break;
1193       default :
1194          return RFAILED;
1195    }
1196    CMCHKPK(oduUnpackUInt32, param->transId, mBuf);
1197    CMCHKPK(cmPkLteLcType, param->lcType, mBuf);
1198    CMCHKPK(cmPkLteLcId, param->lcId, mBuf);
1199    CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
1200    return ROK;
1201 }
1202
1203
1204 \f
1205 /***********************************************************
1206 *
1207 *     Func : cmUnpkRguCDatReqInfo
1208 *
1209 *
1210 *     Desc : RguCDatReqInfo
1211  * DatReq from RLC to MAC for Common Channels(BCCH, PCCH and CCCH)
1212 *
1213 *
1214 *     Ret  : S16
1215 *
1216 *     Notes:
1217 *
1218 *     File  : 
1219 *
1220 **********************************************************/
1221 S16 cmUnpkRguCDatReqInfo
1222 (
1223 RguCDatReqInfo *param,
1224 Buffer *mBuf
1225 )
1226 {
1227    MsgLen msgLen, totalMsgLen;
1228
1229
1230    CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
1231    CMCHKUNPK(cmUnpkLteLcId, &param->lcId, mBuf);
1232    CMCHKUNPK(cmUnpkLteLcType, &param->lcType, mBuf);
1233    CMCHKUNPK(oduPackUInt32, &param->transId, mBuf);
1234    switch(param->lcType) {
1235       case CM_LTE_LCH_BCCH:
1236       case CM_LTE_LCH_PCCH:
1237 #ifdef EMTC_ENABLE
1238          CMCHKUNPK(oduPackUInt8,&param->pnb, mBuf);
1239 #endif
1240          CMCHKUNPK(cmUnpkLteTimingInfo, &param->u.timeToTx, mBuf);
1241          break;
1242       case CM_LTE_LCH_CCCH:
1243          CMCHKUNPK(cmUnpkLteRnti, &param->u.rnti, mBuf);
1244          break;
1245       default :
1246          return RFAILED;
1247    }
1248    SFndLenMsg(mBuf, &msgLen);
1249    if (msgLen > 0)
1250    {
1251       CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf);
1252       if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
1253          return RFAILED;
1254       if (SSegMsg(mBuf, totalMsgLen-msgLen, &param->pdu) != ROK)
1255          return RFAILED;
1256    }
1257    return ROK;
1258 }
1259
1260
1261 \f
1262 /***********************************************************
1263 *
1264 *     Func : cmPkRguLchDatReq
1265 *
1266 *
1267 *     Desc : RguLchDatReq
1268  * DatReq Information of a logical channel
1269 *
1270 *
1271 *     Ret  : S16
1272 *
1273 *     Notes:
1274 *
1275 *     File  : 
1276 *
1277 **********************************************************/
1278 S16 cmPkRguLchDatReq
1279 (
1280 RguLchDatReq *param,
1281 Buffer *mBuf
1282 )
1283 {
1284
1285 #ifdef L2_OPTMZ
1286    CMCHKPK(oduUnpackUInt8, param->freeBuff, mBuf);
1287 #endif
1288    CMCHKPK(oduUnpackUInt8, param->setMaxUlPrio, mBuf);
1289    CMCHKPK(cmPkRguPduInfo, &param->pdu, mBuf);
1290    CMCHKPK(cmPkRguDBoReport, &param->boReport, mBuf);
1291    CMCHKPK(cmPkLteLcId, param->lcId, mBuf);
1292    return ROK;
1293 }
1294
1295
1296 \f
1297 /***********************************************************
1298 *
1299 *     Func : cmUnpkRguLchDatReq
1300 *
1301 *
1302 *     Desc : RguLchDatReq
1303  * DatReq Information of a logical channel
1304 *
1305 *
1306 *     Ret  : S16
1307 *
1308 *     Notes:
1309 *
1310 *     File  : 
1311 *
1312 **********************************************************/
1313 S16 cmUnpkRguLchDatReq
1314 (
1315 RguLchDatReq *param,
1316 Buffer *mBuf
1317 )
1318 {
1319
1320    CMCHKUNPK(cmUnpkLteLcId, &param->lcId, mBuf);
1321    CMCHKUNPK(cmUnpkRguDBoReport, &param->boReport, mBuf);
1322    CMCHKUNPK(cmUnpkRguPduInfo, &param->pdu, mBuf);
1323    CMCHKUNPK(oduPackUInt8, &param->setMaxUlPrio, mBuf);
1324 #ifdef L2_OPTMZ
1325    CMCHKUNPK(oduPackUInt8, &param->freeBuff, mBuf);
1326 #endif
1327    return ROK;
1328 }
1329
1330 \f
1331 /***********************************************************
1332 *
1333 *     Func : cmPkRguDatReqTb
1334 *
1335 *
1336 *     Desc : RguDatReqTb
1337 * DatReq from RLC to MAC for dedicated channels of a UE
1338 *
1339 *
1340 *     Ret  : S16
1341 *
1342 *     Notes:
1343 *
1344 *     File  : 
1345 *
1346 **********************************************************/
1347 S16 cmPkRguDatReqTb
1348 (
1349 RguDatReqTb *param,
1350 Buffer *mBuf
1351 )
1352 {
1353    S32 i;
1354
1355    /*rgu_c_001.main_5 - ADD - L2M Support */
1356 #ifdef LTE_L2_MEAS
1357    CMCHKPK(oduUnpackUInt32, param->tbId, mBuf);
1358 #endif
1359    for (i=param->nmbLch-1; i >= 0; i--) {
1360       CMCHKPK(cmPkRguLchDatReq, &param->lchData[i], mBuf);
1361    }
1362    CMCHKPK(oduUnpackUInt8, param->nmbLch, mBuf);
1363    return ROK;
1364 }
1365
1366
1367 \f
1368 /***********************************************************
1369 *
1370 *     Func : cmUnpkRguDatReqTb
1371 *
1372 *
1373 *     Desc : RguDatReqTb
1374  * DatReq from RLC to MAC for dedicated channels of a UE
1375 *
1376 *
1377 *     Ret  : S16
1378 *
1379 *     Notes:
1380 *
1381 *     File  : 
1382 *
1383 **********************************************************/
1384 #ifdef LTE_L2_MEAS
1385 S16 cmUnpkRguDatReqTb
1386 (
1387 Pst         *pst, 
1388 RguDatReqTb *param,
1389 Buffer *mBuf
1390 )
1391 #else
1392 S16 cmUnpkRguDatReqTb
1393 (
1394 RguDatReqTb *param,
1395 Buffer *mBuf
1396 )
1397 #endif
1398 {
1399    S32 i;
1400
1401
1402    CMCHKUNPK(oduPackUInt8, &param->nmbLch, mBuf);
1403    for (i=0; i<param->nmbLch; i++) {
1404       CMCHKUNPK(cmUnpkRguLchDatReq, &param->lchData[i], mBuf);
1405    }
1406    /*rgu_c_001.main_5 - ADD - L2M Support */
1407 #ifdef LTE_L2_MEAS
1408    CMCHKUNPK(oduPackUInt32, &param->tbId, mBuf);
1409 #endif
1410    return ROK;
1411 }
1412
1413 \f
1414 /***********************************************************
1415 *
1416 *     Func : cmPkRguDDatReqInfo
1417 *
1418 *
1419 *     Desc : RguDDatReqInfo
1420  * DatReq from RLC to MAC for dedicated channels of a UE
1421 *
1422 *
1423 *     Ret  : S16
1424 *
1425 *     Notes:
1426 *
1427 *     File  : 
1428 *
1429 **********************************************************/
1430    /*rgu_c_001.main_5 - ADD - L2M Support */
1431 #ifdef LTE_L2_MEAS
1432 S16 cmPkRguDDatReqInfo
1433 (
1434 Pst            *pst,
1435 RguDDatReqInfo *param,
1436 Buffer *mBuf
1437 )
1438 #else
1439 S16 cmPkRguDDatReqInfo
1440 (
1441 RguDDatReqInfo *param,
1442 Buffer *mBuf
1443 )
1444 #endif
1445 {
1446    S32 i;
1447    S32 idx;
1448
1449
1450    for(idx = (param->nmbOfUeGrantPerTti-1); idx >= 0; idx--)
1451    {
1452       RguDDatReqPerUe *datReq = &param->datReq[idx];
1453       for (i=RGU_MAX_TB-1; i >= 0; i--) 
1454       {
1455          CMCHKPK(cmPkRguDatReqTb, &datReq->datReqTb[i], mBuf);
1456       }
1457       CMCHKPK(oduUnpackUInt8, datReq->nmbOfTbs, mBuf);
1458       CMCHKPK(oduUnpackUInt32, datReq->transId, mBuf);
1459       CMCHKPK(cmPkLteRnti, datReq->rnti, mBuf);
1460    }
1461    CMCHKPK(oduUnpackUInt8, param->nmbOfUeGrantPerTti, mBuf);
1462    CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
1463    return ROK;
1464 }
1465
1466
1467 \f
1468 /***********************************************************
1469 *
1470 *     Func : cmUnpkRguDDatReqInfo
1471 *
1472 *
1473 *     Desc : RguDDatReqInfo
1474  * DatReq from RLC to MAC for dedicated channels of a UE
1475 *
1476 *
1477 *     Ret  : S16
1478 *
1479 *     Notes:
1480 *
1481 *     File  : 
1482 *
1483 **********************************************************/
1484 #ifdef LTE_L2_MEAS
1485 S16 cmUnpkRguDDatReqInfo
1486 (
1487 Pst            *pst, 
1488 RguDDatReqInfo *param,
1489 Buffer *mBuf
1490 )
1491 #else
1492 S16 cmUnpkRguDDatReqInfo
1493 (
1494 RguDDatReqInfo *param,
1495 Buffer *mBuf
1496 )
1497 #endif
1498 {
1499    S32 i;
1500   /* After Merging from 2.1 to 2.2 */
1501    /*rgu_c_001.main_5 - ADD - L2M Support */
1502 #ifdef LTE_L2_MEAS
1503    S16 retVal;
1504 #endif
1505    S32 idx;
1506
1507
1508   /* After Merging from 2.1 to 2.2 */
1509    /*rgu_c_001.main_5 - ADD - L2M Support */
1510 #ifdef LTE_L2_MEAS
1511    retVal = ROK;
1512 #endif
1513    CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
1514    CMCHKUNPK(oduPackUInt8, &param->nmbOfUeGrantPerTti, mBuf);
1515    for(idx = 0; idx < param->nmbOfUeGrantPerTti; idx++)
1516    { 
1517       RguDDatReqPerUe *datReq = &param->datReq[idx];
1518       CMCHKUNPK(cmUnpkLteRnti, &datReq->rnti, mBuf);
1519       CMCHKUNPK(oduPackUInt32, &datReq->transId, mBuf);
1520       CMCHKUNPK(oduPackUInt8, &datReq->nmbOfTbs, mBuf);
1521       /* rgu_c_001.main_4 - Changes for MIMO feature addition */
1522       for (i=0; i<RGU_MAX_TB; i++) 
1523       {
1524          /*rgu_c_001.main_5 - ADD - L2M Support */
1525 #ifdef LTE_L2_MEAS
1526          /* After Merging from 2.1 to 2.2 */
1527          retVal = cmUnpkRguDatReqTb(pst, &datReq->datReqTb[i], mBuf);
1528          if(retVal != ROK)
1529          {
1530             return RFAILED;
1531          }
1532 #else
1533          CMCHKUNPK(cmUnpkRguDatReqTb, &datReq->datReqTb[i], mBuf);
1534 #endif
1535       }
1536    }
1537    return ROK;
1538 }
1539
1540
1541 \f
1542 /***********************************************************
1543 *
1544 *     Func : cmPkRguCDatIndInfo
1545 *
1546 *
1547 *     Desc : RguCDatIndInfo
1548  * DatInd from MAC to RLC on CCCH
1549 *
1550 *
1551 *     Ret  : S16
1552 *
1553 *     Notes:
1554 *
1555 *     File  : 
1556 *
1557 **********************************************************/
1558 S16 cmPkRguCDatIndInfo
1559 (
1560 RguCDatIndInfo *param,
1561 Buffer *mBuf
1562 )
1563 {
1564    MsgLen msgLen;
1565
1566    if (SFndLenMsg(param->pdu, &msgLen) != ROK)
1567       return RFAILED;
1568    if (SCatMsg(mBuf, param->pdu, M1M2) != ROK)
1569       return RFAILED;
1570    SPutMsg(param->pdu);
1571    CMCHKPK(cmPkMsgLen, msgLen, mBuf);
1572    CMCHKPK(cmPkLteLcId, param->lcId, mBuf);
1573    CMCHKPK(cmPkLteRnti, param->rnti, mBuf);
1574    CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
1575    return ROK;
1576 }
1577
1578
1579 \f
1580 /***********************************************************
1581 *
1582 *     Func : cmUnpkRguCDatIndInfo
1583 *
1584 *
1585 *     Desc : RguCDatIndInfo
1586  * DatInd from MAC to RLC on CCCH
1587 *
1588 *
1589 *     Ret  : S16
1590 *
1591 *     Notes:
1592 *
1593 *     File  : 
1594 *
1595 **********************************************************/
1596 S16 cmUnpkRguCDatIndInfo
1597 (
1598 RguCDatIndInfo *param,
1599 Buffer *mBuf
1600 )
1601 {
1602    MsgLen msgLen, totalMsgLen;
1603
1604
1605    CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
1606    CMCHKUNPK(cmUnpkLteRnti, &param->rnti, mBuf);
1607    CMCHKUNPK(cmUnpkLteLcId, &param->lcId, mBuf);
1608    CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf);
1609    if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
1610       return RFAILED;
1611    if (SSegMsg(mBuf, totalMsgLen-msgLen, &param->pdu) != ROK)
1612       return RFAILED;
1613    return ROK;
1614 }
1615
1616
1617 \f
1618 /***********************************************************
1619 *
1620 *     Func : cmPkRguLchDatInd
1621 *
1622 *
1623 *     Desc : RguLchDatInd
1624  * DatInd Information for a logical channel
1625 *
1626 *
1627 *     Ret  : S16
1628 *
1629 *     Notes:
1630 *
1631 *     File  : 
1632 *
1633 **********************************************************/
1634 S16 cmPkRguLchDatInd
1635 (
1636 RguLchDatInd *param,
1637 Buffer *mBuf
1638 )
1639 {
1640
1641    CMCHKPK(cmPkRguPduInfo, &param->pdu, mBuf);
1642    CMCHKPK(cmPkLteLcId, param->lcId, mBuf);
1643    return ROK;
1644 }
1645
1646
1647 \f
1648 /***********************************************************
1649 *
1650 *     Func : cmUnpkRguLchDatInd
1651 *
1652 *
1653 *     Desc : RguLchDatInd
1654  * DatInd Information for a logical channel
1655 *
1656 *
1657 *     Ret  : S16
1658 *
1659 *     Notes:
1660 *
1661 *     File  : 
1662 *
1663 **********************************************************/
1664 S16 cmUnpkRguLchDatInd
1665 (
1666 RguLchDatInd *param,
1667 Buffer *mBuf
1668 )
1669 {
1670
1671    CMCHKUNPK(cmUnpkLteLcId, &param->lcId, mBuf);
1672    CMCHKUNPK(cmUnpkRguPduInfo, &param->pdu, mBuf);
1673    return ROK;
1674 }
1675
1676 \f
1677 /***********************************************************
1678 *
1679 *     Func : cmPkRguCStaRspInfo
1680 *
1681 *
1682 *     Desc : RguCStaRspInfo
1683  * Status Response from RLC to MAC  for common logical channel
1684 *
1685 *
1686 *     Ret  : S16
1687 *
1688 *     Notes:
1689 *
1690 *     File  : 
1691 *
1692 **********************************************************/
1693 S16 cmPkRguCStaRspInfo
1694 (
1695 RguCStaRspInfo *param,
1696 Buffer *mBuf
1697 )
1698 {
1699
1700
1701    switch(param->lcType) {
1702       case CM_LTE_LCH_CCCH:
1703          CMCHKPK(cmPkLteRnti, param->u.rnti, mBuf);
1704          break;
1705       case CM_LTE_LCH_BCCH:
1706       case CM_LTE_LCH_PCCH:
1707          CMCHKPK(cmPkLteTimingInfo, &param->u.timeToTx, mBuf);
1708 #ifdef EMTC_ENABLE
1709          CMCHKPK(oduUnpackUInt8,param->pnb,mBuf);
1710          CMCHKPK(oduUnpackUInt8,param->emtcDiReason,mBuf);
1711 #endif
1712          break;
1713       default :
1714          return RFAILED;
1715    }
1716    CMCHKPK(SPkS32, param->bo, mBuf);
1717    CMCHKPK(cmPkLteLcType, param->lcType, mBuf);
1718    CMCHKPK(cmPkLteLcId, param->lcId, mBuf);
1719    CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
1720    return ROK;
1721 }
1722
1723
1724 \f
1725 /***********************************************************
1726 *
1727 *     Func : cmUnpkRguCStaRspInfo
1728 *
1729 *
1730 *     Desc : RguCStaRspInfo
1731  * Status Response from RLC to MAC  for common logical channel
1732 *
1733 *
1734 *     Ret  : S16
1735 *
1736 *     Notes:
1737 *
1738 *     File  : 
1739 *
1740 **********************************************************/
1741 S16 cmUnpkRguCStaRspInfo
1742 (
1743 RguCStaRspInfo *param,
1744 Buffer *mBuf
1745 )
1746 {
1747
1748
1749    CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
1750    CMCHKUNPK(cmUnpkLteLcId, &param->lcId, mBuf);
1751    CMCHKUNPK(cmUnpkLteLcType, &param->lcType, mBuf);
1752    CMCHKUNPK(SUnpkS32, &param->bo, mBuf);
1753    switch(param->lcType) {
1754       case CM_LTE_LCH_BCCH:
1755       case CM_LTE_LCH_PCCH:
1756 #ifdef EMTC_ENABLE
1757          CMCHKUNPK(oduPackUInt8,&param->emtcDiReason , mBuf);
1758          CMCHKUNPK(oduPackUInt8,&param->pnb , mBuf);
1759 #endif
1760          CMCHKUNPK(cmUnpkLteTimingInfo, &param->u.timeToTx, mBuf);
1761          break;
1762       case CM_LTE_LCH_CCCH:
1763          CMCHKUNPK(cmUnpkLteRnti, &param->u.rnti, mBuf);
1764          break;
1765       default :
1766          return RFAILED;
1767    }
1768    return ROK;
1769 }
1770
1771 \f
1772 /***********************************************************
1773 *
1774 *     Func : cmPkRguLchStaInd
1775 *
1776 *
1777 *     Desc : RguLchStaInd
1778  * StaInd info for each logical channel of a UE
1779 *
1780 *
1781 *     Ret  : S16
1782 *
1783 *     Notes:
1784 *
1785 *     File  : 
1786 *
1787 **********************************************************/
1788 S16 cmPkRguLchStaInd
1789 (
1790 RguLchStaInd *param,
1791 Buffer *mBuf
1792 )
1793 {
1794
1795
1796    CMCHKPK(SPkS16, param->totBufSize, mBuf);
1797    CMCHKPK(cmPkLteLcId, param->lcId, mBuf);
1798    return ROK;
1799 }
1800
1801
1802 \f
1803 /***********************************************************
1804 *
1805 *     Func : cmUnpkRguLchStaInd
1806 *
1807 *
1808 *     Desc : RguLchStaInd
1809  * StaInd info for each logical channel of a UE
1810 *
1811 *
1812 *     Ret  : S16
1813 *
1814 *     Notes:
1815 *
1816 *     File  : 
1817 *
1818 **********************************************************/
1819 S16 cmUnpkRguLchStaInd
1820 (
1821 RguLchStaInd *param,
1822 Buffer *mBuf
1823 )
1824 {
1825
1826    CMCHKUNPK(cmUnpkLteLcId, &param->lcId, mBuf);
1827    CMCHKUNPK(SUnpkS16, &param->totBufSize, mBuf);
1828    return ROK;
1829 }
1830
1831 \f
1832 /***********************************************************
1833 *
1834 *     Func : cmPkRguStaIndTb
1835 *
1836 *
1837 *     Desc : RguStaIndTb
1838 * StaInd from RLC to MAC for dedicated channels of a UE
1839 *
1840 *
1841 *     Ret  : S16
1842 *
1843 *     Notes:
1844 *
1845 *     File  : 
1846 *
1847 **********************************************************/
1848 S16 cmPkRguStaIndTb
1849 (
1850 RguStaIndTb *param,
1851 Buffer *mBuf
1852 )
1853 {
1854    S32 i;
1855
1856
1857 #ifdef LTE_L2_MEAS
1858    CMCHKPK(oduUnpackUInt16, param->status, mBuf);
1859    CMCHKPK(oduUnpackUInt32, param->tbId, mBuf);
1860 #endif   
1861    for (i=param->nmbLch-1; i >= 0; i--) {
1862       CMCHKPK(cmPkRguLchStaInd, &param->lchStaInd[i], mBuf);
1863    }
1864    CMCHKPK(oduUnpackUInt8, param->nmbLch, mBuf);
1865    return ROK;
1866 }
1867
1868
1869 \f
1870 /***********************************************************
1871 *
1872 *     Func : cmUnpkRguStaIndTb
1873 *
1874 *
1875 *     Desc : RguStaIndTb
1876 * StaInd from RLC to MAC for dedicated channels of a UE
1877 *
1878 *
1879 *     Ret  : S16
1880 *
1881 *     Notes:
1882 *
1883 *     File  : 
1884 *
1885 **********************************************************/
1886 S16 cmUnpkRguStaIndTb
1887 (
1888 RguStaIndTb *param,
1889 Buffer *mBuf
1890 )
1891 {
1892    S32 i;
1893
1894    CMCHKUNPK(oduPackUInt8, &param->nmbLch, mBuf);
1895    for (i=0; i<param->nmbLch; i++) {
1896       CMCHKUNPK(cmUnpkRguLchStaInd, &param->lchStaInd[i], mBuf);
1897    }
1898 #ifdef LTE_L2_MEAS
1899    CMCHKUNPK(oduPackUInt32, &param->tbId, mBuf);
1900    CMCHKUNPK(oduPackUInt16, &param->status, mBuf);
1901 #endif   
1902    return ROK;
1903 }
1904
1905 #endif
1906
1907 /**********************************************************************
1908          End of file
1909 **********************************************************************/