Merge "Added a new Flag ODU_LWR_MAC_DEBUG in the code"
[o-du/l2.git] / src / cm / rgm.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 \f
19
20 /************************************************************************
21  
22      Name:     LTE-MAC layer
23   
24      Type:     C source file
25   
26      Desc:     C source code for packing/unpacking of RGM interface
27                primitives.
28   
29      File:     rgm.c 
30   
31 **********************************************************************/
32
33 /** @file rgm.c
34 @brief This file contains the packing/unpacking code for the RGM interface 
35        primitives.
36 */
37
38 /* header include files (.h) */
39 #include "common_def.h"
40 #include "rgm.h"           /* RGM Interface defines */
41 /* header/extern include files (.x) */
42 #include "rgm.x"           /* RGM Interface includes */
43
44 #ifdef RGM_LWLC
45
46 \f
47 /**
48 * @brief Request from RRM to MAC to bind the interface saps
49 *
50 * @details
51 *
52 *     Function : cmPkLwLcRgmBndReq
53 *
54 *  @param[in]   Pst*  pst
55 *  @param[in]   SuId  suId
56 *  @param[in]   SpId  spId
57 *  @return   S16
58 *      -# ROK
59 **/
60 #ifdef ANSI
61 S16 cmPkLwLcRgmBndReq
62 (
63 Pst* pst,
64 SuId suId,
65 SpId spId
66 )
67 #else
68 S16 cmPkLwLcRgmBndReq(pst, suId, spId)
69 Pst* pst;
70 SuId suId;
71 SpId spId;
72 #endif
73 {
74    Buffer *mBuf = NULLP;
75
76    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
77    {
78       return RFAILED;
79    }
80
81    if (SPkS16(spId, mBuf) != ROK) 
82    {
83       SPutMsg(mBuf);
84       return RFAILED;
85    }
86
87    if (SPkS16(suId, mBuf) != ROK) 
88    {
89       SPutMsg(mBuf);
90       return RFAILED;
91    }
92
93    pst->event = (Event) EVTRGMBNDREQ;
94    return (SPstTsk(pst,mBuf));
95 }
96
97 \f
98 /**
99 * @brief Request from RRM to MAC to bind the interface saps
100 *
101 * @details
102 *
103 *     Function : cmUnpkLwLcRgmBndReq
104 *
105 *  @param[in]   Pst*  pst
106 *  @param[in]   SuId  suId
107 *  @param[in]   SpId  spId
108 *  @return   S16
109 *      -# ROK
110 **/
111 #ifdef ANSI
112 S16 cmUnpkLwLcRgmBndReq
113 (
114 RgmBndReq func,
115 Pst *pst,
116 Buffer *mBuf
117 )
118 #else
119 S16 cmUnpkLwLcRgmBndReq(func, pst, mBuf)
120 RgmBndReq func;
121 Pst *pst;
122 Buffer *mBuf;
123 #endif
124 {
125    SuId suId;
126    SpId spId;
127    S16  ret;
128    
129
130    if (SUnpkS16(&suId, mBuf) != ROK) 
131    {
132       SPutMsg(mBuf);
133       return RFAILED;
134    }
135
136    if (SUnpkS16(&spId, mBuf) != ROK) 
137    {
138       SPutMsg(mBuf);
139       return RFAILED;
140    }
141
142    ret = ((*func)(pst, suId, spId));
143
144    SPutMsg(mBuf);
145
146    return (ret);
147 }
148
149 /**
150 * @brief Request from RRM to MAC to Unbind the interface saps
151 *
152 * @details
153 *
154 *     Function : cmPkLwLcRgmUbndReq
155 *
156 *  @param[in]   Pst*  pst
157 *  @param[in]   SpId  spId
158 *  @param[in]   Reason  reason
159 *  @return   S16
160 *      -# ROK
161 **/
162 #ifdef ANSI
163 S16 cmPkLwLcRgmUbndReq
164 (
165 Pst* pst,
166 SpId spId,
167 Reason reason
168 )
169 #else
170 S16 cmPkLwLcRgmUbndReq(pst, spId, reason)
171 Pst* pst;
172 SpId spId;
173 Reason reason;
174 #endif
175 {
176    Buffer *mBuf = NULLP;
177
178    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
179    {
180       return RFAILED;
181    }
182    if (SPkS16(reason, mBuf) != ROK) 
183    {
184       SPutMsg(mBuf);
185       return RFAILED;
186    }
187    if (SPkS16(spId, mBuf) != ROK) 
188    {
189       SPutMsg(mBuf);
190       return RFAILED;
191    }
192
193    pst->event = (Event) EVTRGMUBNDREQ;
194    return (SPstTsk(pst,mBuf));
195 }
196
197 /**
198 * @brief Confirmation from MAC to RRM for the bind/Unbind 
199  * request for the interface saps
200 *
201 * @details
202 *
203 *     Function : cmPkLwLcRgmBndCfm
204 *
205 *  @param[in]   Pst*  pst
206 *  @param[in]   SuId  suId
207 *  @param[in]   U8  status
208 *  @return   S16
209 *      -# ROK
210 **/
211 #ifdef ANSI
212 S16 cmPkLwLcRgmBndCfm
213 (
214 Pst* pst,
215 SuId suId,
216 U8 status
217 )
218 #else
219 S16 cmPkLwLcRgmBndCfm(pst, suId, status)
220 Pst* pst;
221 SuId suId;
222 U8 status;
223 #endif
224 {
225    Buffer *mBuf = NULLP;
226
227    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
228    {
229       return RFAILED;
230    }
231
232    if (SPkS16(suId, mBuf) != ROK) 
233    {
234       SPutMsg(mBuf);
235       return RFAILED;
236    }
237
238    if (oduUnpackUInt8(status, mBuf) != ROK) 
239    {
240       SPutMsg(mBuf);
241       return RFAILED;
242    }
243
244   pst->event = (Event) EVTRGMBNDCFM;
245    return (SPstTsk(pst,mBuf));
246 }
247
248 \f
249 /**
250 * @brief Confirmation from MAC to RRM for the bind/Unbind 
251  * request for the interface saps
252 *
253 * @details
254 *
255 *     Function : cmUnpkLwLcRgmBndCfm
256 *
257 *  @param[in]   Pst*  pst
258 *  @param[in]   SuId  suId
259 *  @param[in]   U8  status
260 *  @return   S16
261 *      -# ROK
262 **/
263 #ifdef ANSI
264 S16 cmUnpkLwLcRgmBndCfm
265 (
266 RgmBndCfm func,
267 Pst *pst,
268 Buffer *mBuf
269 )
270 #else
271 S16 cmUnpkLwLcRgmBndCfm(func, pst, mBuf)
272 RgmBndCfm func;
273 Pst *pst;
274 Buffer *mBuf;
275 #endif
276 {
277    SuId suId;
278    U8 status;
279    
280
281    if (oduPackUInt8(&status, mBuf) != ROK) 
282    {
283       SPutMsg(mBuf);
284       return RFAILED;
285    }
286
287    if (SUnpkS16(&suId, mBuf) != ROK) 
288    {
289       SPutMsg(mBuf);
290       return RFAILED;
291    }
292    SPutMsg(mBuf);
293    return ((*func)(pst, suId, status));
294 }
295
296 \f
297 /**
298 * @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC 
299 *
300 * @details
301 *
302 *     Function : cmPkLwLcRgmCfgPrbRprt
303 *
304 *  @param[in]   Pst*  pst
305 *  @param[in]   SpId  spId
306 *  @param[in]   RgmPrbRprtCfg  *  prbRprtCfg
307 *  @return   S16
308 *      -# ROK
309 **/
310 #ifdef ANSI
311 S16 cmPkLwLcRgmCfgPrbRprt
312 (
313 Pst* pst,
314 SpId spId,
315 RgmPrbRprtCfg  * prbRprtCfg
316 )
317 #else
318 S16 cmPkLwLcRgmCfgPrbRprt(pst, spId, prbRprtCfg)
319 Pst* pst;
320 SpId spId;
321 RgmPrbRprtCfg  * prbRprtCfg;
322 #endif
323 {
324    Buffer *mBuf = NULLP;
325    U32 len = sizeof(RgmPrbRprtCfg);
326
327    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
328    {
329       SPutSBuf(pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg));
330       return RFAILED;
331    }
332
333     if(oduPackPointer((PTR)prbRprtCfg, mBuf) != ROK)
334     {
335        SPutMsg(mBuf); 
336        SPutSBuf(pst->region, pst->pool, (Data*)prbRprtCfg, len);
337        return RFAILED;
338     }
339
340    if (SPkS16(spId, mBuf) != ROK) 
341    {
342       SPutSBuf(pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg));
343       SPutMsg(mBuf);
344       return RFAILED;
345    }
346
347    pst->event = (Event) EVTRGMCFGPRBRPRT;
348    return (SPstTsk(pst,mBuf));
349 }
350
351 \f
352 /**
353 * @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC 
354 *
355 * @details
356 *
357 *     Function : cmUnpkLwLcRgmCfgPrbRprt
358 *
359 *  @param[in]   Pst*  pst
360 *  @param[in]   SpId  spId
361 *  @param[in]   RgmPrbRprtCfg  *  prbRprtCfg
362 *  @return   S16
363 *      -# ROK
364 **/
365 #ifdef ANSI
366 S16 cmUnpkLwLcRgmCfgPrbRprt
367 (
368 RgmCfgPrbRprtFptr func,
369 Pst *pst,
370 Buffer *mBuf
371 )
372 #else
373 S16 cmUnpkLwLcRgmCfgPrbRprt(func, pst, mBuf)
374 RgmCfgPrbRprtFptr func;
375 Pst *pst;
376 Buffer *mBuf;
377 #endif
378 {
379    S16 ret;
380    SpId spId;
381    RgmPrbRprtCfg *prbRprtCfg;
382    
383
384    if (SUnpkS16(&spId, mBuf) != ROK) 
385    {
386       SPutMsg(mBuf);
387       return RFAILED;
388    }
389
390    if (oduUnpackPointer((PTR *)&prbRprtCfg, mBuf) != ROK)
391    {
392       SPutMsg(mBuf);
393       SPutSBuf(pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg));
394       return RFAILED;
395    }
396
397    ret =  ((*func)(pst, spId, prbRprtCfg));
398
399    SPutMsg(mBuf);
400    return (ret);
401 }
402
403
404 /**
405 * @brief PRB Usage Report Indication  from MAC to RRM 
406 *
407 * @details
408 *
409 *     Function : cmPkLwLcRgmPrbRprtInd
410 *
411 *  @param[in]   Pst*  pst
412 *  @param[in]   SuId  suId
413 *  @param[in]   RgmPrbRprtInd  *  prbRprtInd
414 *  @return   S16
415 *      -# ROK
416 **/
417 #ifdef ANSI
418 S16 cmPkLwLcRgmPrbRprtInd
419 (
420 Pst* pst,
421 SuId suId,
422 RgmPrbRprtInd  * prbRprtInd
423 )
424 #else
425 S16 cmPkLwLcRgmPrbRprtInd(pst, suId, prbRprtInd)
426 Pst* pst;
427 SuId suId;
428 RgmPrbRprtInd  * prbRprtInd;
429 #endif
430 {
431    Buffer *mBuf = NULLP;
432
433
434    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
435       SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
436       return RFAILED;
437    }
438
439    if(oduPackPointer((PTR)prbRprtInd, mBuf) != ROK)
440    {
441       SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
442       SPutMsg(mBuf);
443       return RFAILED;
444    }
445
446    if (SPkS16(suId, mBuf) != ROK) 
447    {
448       SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
449       SPutMsg(mBuf);
450       return RFAILED;
451    }
452
453    pst->event = (Event) EVTRGMCFGPRBRPRT;
454    return (SPstTsk(pst,mBuf));
455 }
456
457
458 /**
459 * @brief PRB Usage Report Indication from MAC to RRM 
460 *
461 * @details
462 *
463 *     Function : cmUnpkLwLcRgmPrbRprtInd
464 *
465 *  @param[in]   Pst*  pst
466 *  @param[in]   SuId  suId
467 *  @param[in]   RgmPrbRprtInd  *  prbRprtInd
468 *  @return   S16
469 *      -# ROK
470 **/
471 #ifdef ANSI
472 S16 cmUnpkLwLcRgmPrbRprtInd
473 (
474 RgmPrbRprtIndFptr func,
475 Pst *pst,
476 Buffer *mBuf
477 )
478 #else
479 S16 cmUnpkLwLcRgmPrbRprtInd(func, pst, mBuf)
480 RgmPrbRprtIndFptr func;
481 Pst *pst;
482 Buffer *mBuf;
483 #endif
484 {
485    SuId suId;
486    RgmPrbRprtInd *prbRprtInd;
487    S16 ret;
488    
489
490    if (SUnpkS16(&suId, mBuf) != ROK) 
491    {
492       SPutMsg(mBuf);
493       return RFAILED;
494    }
495
496    if (oduUnpackPointer((PTR *)&prbRprtInd, mBuf) != ROK) 
497    {
498       SPutMsg(mBuf);
499       SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
500       return RFAILED;
501    }
502
503
504    ret = ((*func)(pst, suId, prbRprtInd));
505
506    SPutMsg(mBuf);
507
508    return (ret);
509 }
510 #endif
511
512
513 /**
514 * @brief Request from RRM to MAC to bind the interface saps
515 *
516 * @details
517 *
518 *     Function : cmPkRgmBndReq
519 *
520 *  @param[in]   Pst*  pst
521 *  @param[in]   SuId  suId
522 *  @param[in]   SpId  spId
523 *  @return   S16
524 *      -# ROK
525 **/
526 #ifdef ANSI
527 S16 cmPkRgmBndReq
528 (
529 Pst* pst,
530 SuId suId,
531 SpId spId
532 )
533 #else
534 S16 cmPkRgmBndReq(pst, suId, spId)
535 Pst* pst;
536 SuId suId;
537 SpId spId;
538 #endif
539 {
540    Buffer *mBuf = NULLP;
541
542    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
543    {
544       return RFAILED;
545    }
546
547    if (SPkS16(spId, mBuf) != ROK) 
548    {
549       SPutMsg(mBuf);
550       return RFAILED;
551    }
552
553    if (SPkS16(suId, mBuf) != ROK) 
554    {
555       SPutMsg(mBuf);
556       return RFAILED;
557    }
558
559    pst->event = (Event) EVTRGMBNDREQ;
560    return (SPstTsk(pst,mBuf));
561 }
562
563 \f
564 /**
565 * @brief Request from RRM to MAC to bind the interface saps
566 *
567 * @details
568 *
569 *     Function : cmUnpkRgmBndReq
570 *
571 *  @param[in]   Pst*  pst
572 *  @param[in]   SuId  suId
573 *  @param[in]   SpId  spId
574 *  @return   S16
575 *      -# ROK
576 **/
577 #ifdef ANSI
578 S16 cmUnpkRgmBndReq
579 (
580 RgmBndReq func,
581 Pst *pst,
582 Buffer *mBuf
583 )
584 #else
585 S16 cmUnpkRgmBndReq(func, pst, mBuf)
586 RgmBndReq func;
587 Pst *pst;
588 Buffer *mBuf;
589 #endif
590 {
591    SuId suId;
592    SpId spId;
593    S16  ret;
594    
595
596    if (SUnpkS16(&suId, mBuf) != ROK) 
597    {
598       SPutMsg(mBuf);
599       return RFAILED;
600    }
601
602    if (SUnpkS16(&spId, mBuf) != ROK) 
603    {
604       SPutMsg(mBuf);
605       return RFAILED;
606    }
607
608    ret = ((*func)(pst, suId, spId));
609
610    SPutMsg(mBuf);
611
612    return (ret);
613 }
614
615 /**
616 * @brief Request from RRM to MAC to Unbind the interface saps
617 *
618 * @details
619 *
620 *     Function : cmPkRgmUbndReq
621 *
622 *  @param[in]   Pst*  pst
623 *  @param[in]   SpId  spId
624 *  @param[in]   Reason  reason
625 *  @return   S16
626 *      -# ROK
627 **/
628 #ifdef ANSI
629 S16 cmPkRgmUbndReq
630 (
631 Pst* pst,
632 SpId spId,
633 Reason reason
634 )
635 #else
636 S16 cmPkRgmUbndReq(pst, spId, reason)
637 Pst* pst;
638 SpId spId;
639 Reason reason;
640 #endif
641 {
642    Buffer *mBuf = NULLP;
643
644    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
645    {
646       return RFAILED;
647    }
648    if (SPkS16(reason, mBuf) != ROK) 
649    {
650       SPutMsg(mBuf);
651       return RFAILED;
652    }
653    if (SPkS16(spId, mBuf) != ROK) 
654    {
655       SPutMsg(mBuf);
656       return RFAILED;
657    }
658
659    pst->event = (Event) EVTRGMUBNDREQ;
660    return (SPstTsk(pst,mBuf));
661 }
662
663 #if 1 
664 \f
665 /**
666 * @brief Request from RRM to MAC to Unbind the interface saps
667 *
668 * @details
669 *
670 *     Function : cmUnpkRgmUbndReq
671 *
672 *  @param[in]   Pst*  pst
673 *  @param[in]   SpId  spId
674 *  @param[in]   Reason  reason
675 *  @return   S16
676 *      -# ROK
677 **/
678 #ifdef ANSI
679 S16 cmUnpkRgmUbndReq
680 (
681 RgmUbndReq func,
682 Pst *pst,
683 Buffer *mBuf
684 )
685 #else
686 S16 cmUnpkRgmUbndReq(func, pst, mBuf)
687 RgmUbndReq func;
688 Pst *pst;
689 Buffer *mBuf;
690 #endif
691 {
692    SpId spId;
693    Reason reason;
694    
695
696    if (SUnpkS16(&spId, mBuf) != ROK) 
697    {
698       SPutMsg(mBuf);
699       return RFAILED;
700    }
701    if (SUnpkS16(&reason, mBuf) != ROK)
702    {
703       SPutMsg(mBuf);
704       return RFAILED;
705    }
706    SPutMsg(mBuf);
707    return ((*func)(pst, spId, reason));
708 }
709 #endif
710
711 /**
712 * @brief Confirmation from MAC to RRM for the bind/Unbind 
713  * request for the interface saps
714 *
715 * @details
716 *
717 *     Function : cmPkRgmBndCfm
718 *
719 *  @param[in]   Pst*  pst
720 *  @param[in]   SuId  suId
721 *  @param[in]   U8  status
722 *  @return   S16
723 *      -# ROK
724 **/
725 #ifdef ANSI
726 S16 cmPkRgmBndCfm
727 (
728 Pst* pst,
729 SuId suId,
730 U8 status
731 )
732 #else
733 S16 cmPkRgmBndCfm(pst, suId, status)
734 Pst* pst;
735 SuId suId;
736 U8 status;
737 #endif
738 {
739    Buffer *mBuf = NULLP;
740
741    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
742    {
743       return RFAILED;
744    }
745
746    if (SPkS16(suId, mBuf) != ROK) 
747    {
748       SPutMsg(mBuf);
749       return RFAILED;
750    }
751
752    if (oduUnpackUInt8(status, mBuf) != ROK) 
753    {
754       SPutMsg(mBuf);
755       return RFAILED;
756    }
757
758   pst->event = (Event) EVTRGMBNDCFM;
759    return (SPstTsk(pst,mBuf));
760 }
761
762 \f
763 /**
764 * @brief Confirmation from MAC to RRM for the bind/Unbind 
765  * request for the interface saps
766 *
767 * @details
768 *
769 *     Function : cmUnpkRgmBndCfm
770 *
771 *  @param[in]   Pst*  pst
772 *  @param[in]   SuId  suId
773 *  @param[in]   U8  status
774 *  @return   S16
775 *      -# ROK
776 **/
777 #ifdef ANSI
778 S16 cmUnpkRgmBndCfm
779 (
780 RgmBndCfm func,
781 Pst *pst,
782 Buffer *mBuf
783 )
784 #else
785 S16 cmUnpkRgmBndCfm(func, pst, mBuf)
786 RgmBndCfm func;
787 Pst *pst;
788 Buffer *mBuf;
789 #endif
790 {
791    SuId suId;
792    U8 status;
793    
794
795    if (oduPackUInt8(&status, mBuf) != ROK) 
796    {
797       SPutMsg(mBuf);
798       return RFAILED;
799    }
800
801    if (SUnpkS16(&suId, mBuf) != ROK) 
802    {
803       SPutMsg(mBuf);
804       return RFAILED;
805    }
806    SPutMsg(mBuf);
807    return ((*func)(pst, suId, status));
808 }
809
810 \f
811
812
813 /**
814 * @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC 
815 *
816 * @details
817 *
818 *     Function : cmPkCfgPrbRprt
819 *
820 *  @param[in]   RgmPrbRprtCfg  *prbRprtCfg
821 *  @param[in]   Buffer *mBuf 
822 *  @return   S16
823 *      -# ROK
824 **/
825 #ifdef ANSI
826 S16 cmPkCfgPrbRprt
827 (
828 RgmPrbRprtCfg  * prbRprtCfg,
829 Buffer *mBuf
830 )
831 #else
832 S16 cmPkCfgPrbRprt(prbRprtCfg, mBuf)
833 RgmPrbRprtCfg  * prbRprtCfg;
834 Buffer *mBuf;
835 #endif
836 {
837    CMCHKPK(oduUnpackUInt16, prbRprtCfg->usPrbAvgPeriodicty, mBuf);
838    CMCHKPK(oduUnpackUInt8, prbRprtCfg->bConfigType, mBuf);
839    CMCHKPK(oduUnpackUInt8, prbRprtCfg->bCellId, mBuf);
840    return ROK;
841 }
842 /**
843 * @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC 
844 *
845 * @details
846 *
847 *     Function : cmUnPkCfgPrbRprt
848 *
849 *  @param[in]   RgmPrbRprtCfg  *prbRprtCfg
850 *  @param[in]   Buffer *mBuf 
851 *  @return   S16
852 *      -# ROK
853 **/
854 #ifdef ANSI
855 S16 cmUnPkCfgPrbRprt
856 (
857 RgmPrbRprtCfg  * prbRprtCfg,
858 Buffer *mBuf
859 )
860 #else
861 S16 cmUnPkCfgPrbRprt(prbRprtCfg, mBuf)
862 RgmPrbRprtCfg  * prbRprtCfg;
863 Buffer *mBuf;
864 #endif
865 {
866    CMCHKUNPK(oduPackUInt8, &prbRprtCfg->bCellId, mBuf);
867    CMCHKUNPK(oduPackUInt8, &prbRprtCfg->bConfigType, mBuf);
868    CMCHKUNPK(oduPackUInt16, &prbRprtCfg->usPrbAvgPeriodicty, mBuf);
869    return ROK;
870 }
871
872
873
874 \f
875 /**
876 * @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC 
877 *
878 * @details
879 *
880 *     Function : cmPkRgmCfgPrbRprt
881 *
882 *  @param[in]   Pst*  pst
883 *  @param[in]   SpId  spId
884 *  @param[in]   RgmPrbRprtCfg  *prbRprtCfg
885 *  @return   S16
886 *      -# ROK
887 **/
888 #ifdef ANSI
889 S16 cmPkRgmCfgPrbRprt
890 (
891 Pst* pst,
892 SpId spId,
893 RgmPrbRprtCfg  * prbRprtCfg
894 )
895 #else
896 S16 cmPkRgmCfgPrbRprt(pst, spId, prbRprtCfg)
897 Pst* pst;
898 SpId spId;
899 RgmPrbRprtCfg  * prbRprtCfg;
900 #endif
901 {
902    Buffer *mBuf = NULLP;
903    U32 len = sizeof(RgmPrbRprtCfg);
904
905    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
906    {
907       SPutSBuf(pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg));
908       return RFAILED;
909    }
910
911     if(cmPkCfgPrbRprt(prbRprtCfg, mBuf) != ROK)
912     {
913        SPutMsg(mBuf); 
914        SPutSBuf(pst->region, pst->pool, (Data*)prbRprtCfg, len);
915        return RFAILED;
916     }
917
918    if (SPkS16(spId, mBuf) != ROK) 
919    {
920       SPutSBuf(pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg));
921       SPutMsg(mBuf);
922       return RFAILED;
923    }
924
925    SPutSBuf(pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg));
926
927    pst->event = (Event) EVTRGMCFGPRBRPRT;
928    return (SPstTsk(pst,mBuf));
929 }
930
931
932
933 /**
934 * @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC 
935 *
936 * @details
937 *
938 *     Function : cmUnpkRgmCfgPrbRprt
939 *
940 *  @param[in]   Pst*  pst
941 *  @param[in]   SpId  spId
942 *  @param[in]   RgmPrbRprtCfg  *  prbRprtCfg
943 *  @return   S16
944 *      -# ROK
945 **/
946 #ifdef ANSI
947 S16 cmUnpkRgmCfgPrbRprt
948 (
949 RgmCfgPrbRprtFptr func,
950 Pst *pst,
951 Buffer *mBuf
952 )
953 #else
954 S16 cmUnpkRgmCfgPrbRprt(func, pst, mBuf)
955 RgmCfgPrbRprtFptr func;
956 Pst *pst;
957 Buffer *mBuf;
958 #endif
959 {
960    SpId spId;
961    RgmPrbRprtCfg *prbRprtCfg;
962
963    if ((SGetSBuf(pst->region, pst->pool, (Data **)&prbRprtCfg, sizeof(RgmPrbRprtCfg))) != ROK)
964       {
965          SPutMsg(mBuf);
966          return RFAILED;
967       }
968
969    if (SUnpkS16(&spId, mBuf) != ROK) 
970    {
971       SPutMsg(mBuf);
972       return RFAILED;
973    }
974
975    if (cmUnPkCfgPrbRprt(prbRprtCfg, mBuf) != ROK)
976    {
977       SPutMsg(mBuf);
978       return RFAILED;
979    }
980
981    SPutMsg(mBuf);
982    return ((*func)(pst, spId, prbRprtCfg));
983 }
984
985 /* RRM_SP1_START */
986 /**
987 * @brief Packing of PRB Usage Report for qci for sending 
988 *        to RRM from MAC 
989 *
990 * @details
991 *
992 *     Function : cmPkRgmPrbQciRpt 
993 *
994 *  @param[in]   RgmPrbRptPerQci * qciPrbRprt 
995 *  @param[out]   Buffer *mBuf 
996 *  @return   S16
997 *      -# ROK
998 **/
999 #ifdef ANSI
1000 S16 cmPkRgmPrbQciRpt 
1001 (
1002  RgmPrbRptPerQci *qciPrbRprt,
1003  Buffer *mBuf
1004  )
1005 #else
1006 S16 cmPkRgmPrbQciRpt(qciPrbRprt, mBuf)
1007 RgmPrbRptPerQci *qciPrbRprt;
1008 Buffer *mBuf = NULLP;
1009 #endif
1010 {
1011    CMCHKPK(oduUnpackUInt8, qciPrbRprt->bQci, mBuf);
1012    CMCHKPK(oduUnpackUInt8, qciPrbRprt->bAvgPrbUlUsage, mBuf);
1013    CMCHKPK(oduUnpackUInt8, qciPrbRprt->bAvgPrbDlUsage, mBuf);
1014
1015    return ROK;
1016 }
1017
1018 /**
1019 * @brief Unpacking of PRB Usage Report for qci received from MAC 
1020 *
1021 * @details
1022 *
1023 *     Function : cmUnpkRgmPrbQciRpt 
1024 *
1025 *  @param[out]   RgmPrbRptPerQci * qciPrbRprt 
1026 *  @param[in]   Buffer *mBuf 
1027 *  @return   S16
1028 *      -# ROK
1029 **/
1030 #ifdef ANSI
1031 S16 cmUnpkRgmPrbQciRpt 
1032 (
1033  RgmPrbRptPerQci *qciPrbRprt,
1034  Buffer *mBuf
1035  )
1036 #else
1037 S16 cmUnpkRgmPrbQciRpt(qciPrbRprt, mBuf)
1038 RgmPrbRptPerQci *qciPrbRprt;
1039 Buffer *mBuf = NULLP;
1040 #endif
1041 {
1042    CMCHKUNPK(oduPackUInt8, &qciPrbRprt->bAvgPrbDlUsage, mBuf);
1043    CMCHKUNPK(oduPackUInt8, &qciPrbRprt->bAvgPrbUlUsage, mBuf);
1044    CMCHKUNPK(oduPackUInt8, &qciPrbRprt->bQci, mBuf);
1045
1046    return ROK;
1047 }
1048 /* RRM_SP1_END */
1049
1050 /**
1051 * @brief PRB Usage Report Indication  from MAC to RRM 
1052 *
1053 * @details
1054 *
1055 *     Function : cmPkPrbRprtInd
1056 *
1057 *  @param[in]   RgmPrbRprtInd  *  prbRprtInd
1058 *  @param[in]   Buffer *mBuf 
1059 *  @return   S16
1060 *      -# ROK
1061 **/
1062 #ifdef ANSI
1063 S16 cmPkPrbRprtInd
1064 (
1065  RgmPrbRprtInd  * prbRprtInd,
1066  Buffer *mBuf
1067  )
1068 #else
1069 S16 cmPkPrbRprtInd(prbRprtInd, mBuf)
1070    RgmPrbRprtInd  * prbRprtInd;
1071    Buffer *mBuf = NULLP;
1072 #endif
1073 {
1074    S32 idx = 0;
1075
1076    
1077    /* RRM_SP1_START */
1078    for(idx = RGM_MAX_QCI_REPORTS-1; idx >= 0; idx--)
1079    {
1080       CMCHKPK(cmPkRgmPrbQciRpt, &prbRprtInd->stQciPrbRpts[idx], mBuf);
1081    }
1082    CMCHKPK(oduUnpackUInt8, prbRprtInd->bPrbUsageMask, mBuf);
1083    CMCHKPK(oduUnpackUInt8, prbRprtInd->bCellId, mBuf);
1084    /* RRM_SP1_END */
1085    return ROK;
1086 }
1087
1088 /**
1089 * @brief PRB Usage Report Indication  from MAC to RRM 
1090 *
1091 * @details
1092 *
1093 *     Function : cmUnpkPrbRprtInd
1094 *
1095 *  @param[in]   RgmPrbRprtInd  *  prbRprtInd
1096 *  @param[in]   Buffer *mBuf 
1097 *  @return   S16
1098 *      -# ROK
1099 **/
1100 #ifdef ANSI
1101 S16 cmUnpkPrbRprtInd
1102 (
1103  RgmPrbRprtInd  * prbRprtInd,
1104  Buffer *mBuf
1105  )
1106 #else
1107 S16 cmUnpkPrbRprtInd(prbRprtInd, mBuf)
1108    RgmPrbRprtInd  * prbRprtInd;
1109    Buffer *mBuf;
1110 #endif
1111 {
1112    U32 idx = 0;
1113
1114
1115    /* RRM_SP1_START */
1116    CMCHKUNPK(oduPackUInt8, &prbRprtInd->bCellId, mBuf);
1117    CMCHKUNPK(oduPackUInt8, &prbRprtInd->bPrbUsageMask, mBuf);
1118    for(idx = 0; idx < RGM_MAX_QCI_REPORTS; idx++)
1119    {
1120       CMCHKUNPK(cmUnpkRgmPrbQciRpt, &prbRprtInd->stQciPrbRpts[idx], mBuf);
1121    }
1122
1123    /* RRM_SP1_END */
1124    return ROK;
1125 }
1126
1127
1128
1129 /**
1130 * @brief PRB Usage Report Indication  from MAC to RRM 
1131 *
1132 * @details
1133 *
1134 *     Function : cmPkRgmPrbRprtInd
1135 *
1136 *  @param[in]   Pst*  pst
1137 *  @param[in]   SuId  suId
1138 *  @param[in]   RgmPrbRprtInd  *  prbRprtInd
1139 *  @return   S16
1140 *      -# ROK
1141 **/
1142 #ifdef ANSI
1143 S16 cmPkRgmPrbRprtInd
1144 (
1145 Pst* pst,
1146 SuId suId,
1147 RgmPrbRprtInd  * prbRprtInd
1148 )
1149 #else
1150 S16 cmPkRgmPrbRprtInd(pst, suId, prbRprtInd)
1151 Pst* pst;
1152 SuId suId;
1153 RgmPrbRprtInd  * prbRprtInd;
1154 #endif
1155 {
1156    Buffer *mBuf = NULLP;
1157
1158
1159    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
1160       SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
1161       return RFAILED;
1162    }
1163
1164    if(cmPkPrbRprtInd(prbRprtInd, mBuf) != ROK)
1165    {
1166       SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
1167       SPutMsg(mBuf);
1168       return RFAILED;
1169    }
1170
1171    if (SPkS16(suId, mBuf) != ROK) 
1172    {
1173       SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
1174       SPutMsg(mBuf);
1175       return RFAILED;
1176    }
1177
1178    SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
1179
1180    pst->event = (Event) EVTRGMPRBRPRTIND;
1181    return (SPstTsk(pst,mBuf));
1182 }
1183 /**
1184 * @brief PRB Usage Report Indication from MAC to RRM 
1185 *
1186 * @details
1187 *
1188 *     Function : cmUnpkRgmPrbRprtInd
1189 *
1190 *  @param[in]   Pst*  pst
1191 *  @param[in]   SuId  suId
1192 *  @param[in]   RgmPrbRprtInd  *  prbRprtInd
1193 *  @return   S16
1194 *      -# ROK
1195 **/
1196 #ifdef ANSI
1197 S16 cmUnpkRgmPrbRprtInd
1198 (
1199 RgmPrbRprtIndFptr func,
1200 Pst *pst,
1201 Buffer *mBuf
1202 )
1203 #else
1204 S16 cmUnpkRgmPrbRprtInd(func, pst, mBuf)
1205 RgmPrbRprtIndFptr func;
1206 Pst *pst;
1207 Buffer *mBuf;
1208 #endif
1209 {
1210    SuId suId;
1211    RgmPrbRprtInd prbRprtInd;
1212    
1213
1214    if (SUnpkS16(&suId, mBuf) != ROK) 
1215    {
1216       SPutMsg(mBuf);
1217       return RFAILED;
1218    }
1219
1220    if (cmUnpkPrbRprtInd(&prbRprtInd, mBuf) != ROK) 
1221    {
1222       SPutMsg(mBuf);
1223       return RFAILED;
1224    }
1225
1226    SPutMsg(mBuf);
1227    return ((*func)(pst, suId, &prbRprtInd));
1228 }
1229
1230 /**
1231 * @brief Transmission Mode Change Indication  from MAC to RRM 
1232 *
1233 * @details
1234 *
1235 *     Function : cmPkTransModeInd
1236 *
1237 *  @param[in]   RgmTransModeInd *transModeInd
1238 *  @param[in]   Buffer *mBuf 
1239 *  @return   S16
1240 *      -# ROK
1241 **/
1242 #ifdef ANSI
1243 S16 cmPkTransModeInd
1244 (
1245  RgmTransModeInd *transModeInd,
1246  Buffer *mBuf
1247  )
1248 #else
1249 S16 cmPkTransModeInd(transModeInd, mBuf)
1250    RgmTransModeInd *transModeInd;
1251    Buffer *mBuf;
1252 #endif
1253 {
1254    CMCHKPK(oduUnpackUInt32, transModeInd->eMode, mBuf);
1255    CMCHKPK(oduUnpackUInt16, transModeInd->usCrnti, mBuf);
1256    CMCHKPK(oduUnpackUInt8, transModeInd->bCellId, mBuf);
1257    return ROK;
1258 }
1259
1260 /**
1261 * @brief  Transmission Mode Change Indication from MAC to RRM 
1262 *
1263 * @details
1264 *
1265 *     Function : cmUnpkTransModeInd
1266 *
1267 *  @param[in]   RgmTransModeInd *transModeInd 
1268 *  @param[in]   Buffer *mBuf 
1269 *  @return   S16
1270 *      -# ROK
1271 **/
1272 #ifdef ANSI
1273 S16 cmUnpkTransModeInd
1274 (
1275  RgmTransModeInd *transModeInd,
1276  Buffer *mBuf
1277  )
1278 #else
1279 S16 cmUnpkTransModeInd(transModeInd, mBuf)
1280    RgmTransModeInd *transModeInd;
1281    Buffer *mBuf;
1282 #endif
1283 {
1284    U32 tmpModeEnum;
1285    CMCHKUNPK(oduPackUInt8, &transModeInd->bCellId, mBuf);
1286    CMCHKUNPK(oduPackUInt16, &transModeInd->usCrnti, mBuf);
1287    CMCHKUNPK(oduPackUInt32, (U32 *)&tmpModeEnum, mBuf);
1288    transModeInd->eMode = (RgmTxnMode)tmpModeEnum;
1289    return ROK;
1290 }
1291 /**
1292 * @brief Transmission Mode Change Indication  from MAC to RRM 
1293 *
1294 * @details
1295 *
1296 *     Function : cmPkRgmTransModeInd
1297 *
1298 *  @param[in]   Pst*  pst
1299 *  @param[in]   SuId  suId
1300 *  @param[in]   RgmTransModeInd *transModeInd 
1301 *  @return   S16
1302 *      -# ROK
1303 **/
1304 #ifdef ANSI
1305 S16 cmPkRgmTransModeInd 
1306 (
1307 Pst* pst,
1308 SuId suId,
1309 RgmTransModeInd *transModeInd
1310 )
1311 #else
1312 S16 cmPkRgmTransModeInd(pst, suId, transModeInd)
1313 Pst* pst;
1314 SuId suId;
1315 RgmTransModeInd *transModeInd;
1316 #endif
1317 {
1318    Buffer *mBuf = NULLP;
1319
1320
1321    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
1322       SPutSBuf(pst->region, pst->pool, (Data *)transModeInd, sizeof(RgmTransModeInd));
1323       return RFAILED;
1324    }
1325
1326    if(cmPkTransModeInd(transModeInd, mBuf) != ROK)
1327    {
1328       SPutSBuf(pst->region, pst->pool, (Data *)transModeInd, sizeof(RgmTransModeInd));
1329       SPutMsg(mBuf);
1330       return RFAILED;
1331    }
1332
1333    if (SPkS16(suId, mBuf) != ROK) 
1334    {
1335       SPutSBuf(pst->region, pst->pool, (Data *)transModeInd, sizeof(RgmTransModeInd));
1336       SPutMsg(mBuf);
1337       return RFAILED;
1338    }
1339
1340    SPutSBuf(pst->region, pst->pool, (Data *)transModeInd, sizeof(RgmTransModeInd));
1341
1342    pst->event = (Event) EVTRGMTRANSMODEIND;
1343    return (SPstTsk(pst,mBuf));
1344 }
1345 /**
1346 * @brief Transmission Mode Change Indication  from MAC to RRM 
1347 *
1348 * @details
1349 *
1350 *     Function : cmUnpkRgmTransModeInd
1351 *
1352 *  @param[in]   Pst*  pst
1353 *  @param[in]   SuId  suId
1354 *  @param[in]   RgmTransModeInd *transModeInd 
1355 *  @return   S16
1356 *      -# ROK
1357 **/
1358 #ifdef ANSI
1359 S16 cmUnpkRgmTransModeInd
1360 (
1361 RgmTransModeIndFptr func,
1362 Pst *pst,
1363 Buffer *mBuf
1364 )
1365 #else
1366 S16 cmUnpkRgmTransModeInd(func, pst, mBuf)
1367 RgmTransModeIndFptr func;
1368 Pst *pst;
1369 Buffer *mBuf;
1370 #endif
1371 {
1372    SuId suId;
1373    RgmTransModeInd transModeInd;
1374    
1375
1376    if (SUnpkS16(&suId, mBuf) != ROK) 
1377    {
1378       SPutMsg(mBuf);
1379       return RFAILED;
1380    }
1381
1382    if (cmUnpkTransModeInd(&transModeInd, mBuf) != ROK) 
1383    {
1384       SPutMsg(mBuf);
1385       return RFAILED;
1386    }
1387
1388    SPutMsg(mBuf);
1389    return ((*func)(pst, suId, &transModeInd));
1390 }
1391 /**********************************************************************
1392  
1393          End of file
1394  
1395 **********************************************************************/