[Epic-ID: ODUHIGH-464][Task-ID: ODUHIGH-483] Memeory related fix in FDD and TDD mode
[o-du/l2.git] / src / 5gnrsch / rg_sch_inf.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 INF interface
26                primitives.
27   
28      File:     rg_sch_inf.c 
29   
30 **********************************************************************/
31
32 /* header include files (.h) */
33 #include "common_def.h"
34 #include "tfu.h"           /* RGU defines */
35 #ifdef LTE_L2_MEAS
36 #include "lrg.h"
37 #endif
38 #include "rg_sch_inf.h"    /* RGU Interface defines */
39
40 /* header/extern include files (.x) */
41 #include "tfu.x"           /* RGU defines */
42 #ifdef LTE_L2_MEAS
43 #include "lrg.x"
44 #endif
45 #include "rg_sch_inf.x"    /* RGU Interface includes */
46
47 #ifdef LCSCH
48 /*Fix: start: Inform UE delete to scheduler*/
49 /**
50 * @brief This primitive is used to indicate to scheduler
51 *        that UE has been deleted at MAC.
52 *
53 * @details
54 *
55 *     Function : cmPkMacSchUeDelInd
56 *
57 *  @param[in]   Pst*  pst
58 *  @param[in]   RgInfUeDelInd*  ueDelInd
59 *  @return   S16
60 *      -# ROK
61 **/
62 S16 cmPkMacSchUeDelInd(Pst* pst,RgInfUeDelInd*  ueDelInd)
63 {
64    Buffer *mBuf = NULLP;
65    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) 
66    {
67       return RFAILED;
68    }
69    
70 #ifdef MS_MBUF_CORRUPTION 
71    MS_BUF_ADD_ALLOC_CALLER();
72 #endif 
73    if(SAddPstMsgMult((Data *)ueDelInd, sizeof(RgInfUeDelInd), mBuf) != ROK)
74    {
75       RGSCHINF_FREE_MSG(mBuf);
76       return RFAILED;
77    }
78
79    pst->event = (Event) EVTINFUEDELIND;
80    return (SPstTsk(pst,mBuf));
81 }
82
83 /**
84 * @brief This primitive is used to indicate to scheduler
85 *        that UE has been deleted at MAC.
86 *
87 *
88 * @details
89 *
90 *     Function : cmUnpkMacSchUeDelInd
91 *
92 *  @param[in]   Pst*  pst
93 *  @param[in]   SpId  spId
94 *  @param[in]   RguDDatReqInfo  *  datReq
95 *  @return   S16
96 *      -# ROK
97 **/
98 S16 cmUnpkMacSchUeDelInd(UeDelInd func,Pst *pst,Buffer *mBuf)
99 {
100    RgInfUeDelInd ueDelInd;
101    
102    if(SRemPreMsgMult((Data *)&ueDelInd, sizeof(RgInfUeDelInd), mBuf) != ROK)
103    {
104       RGSCHINF_FREE_MSG(mBuf);
105       return RFAILED;
106    }
107
108    RGSCHINF_FREE_MSG(mBuf);
109
110    return ((*func)(pst, &ueDelInd));
111 }
112 /*Fix: end: Inform UE delete to scheduler*/
113
114 /**
115 * @brief Request from RLC to MAC for forwarding SDUs on 
116  * dedicated channel for transmission.
117 *
118 * @details
119 *
120 *     Function : cmPkMacSchDedBoUpdtReq
121 *
122 *  @param[in]   Pst*  pst
123 *  @param[in]   SpId  spId
124 *  @param[in]   RguDDatReqInfo  *  datReq
125 *  @return   S16
126 *      -# ROK
127 **/
128 S16 cmPkMacSchDedBoUpdtReq(Pst* pst,RgInfDedBoRpt* boRpt)
129 {
130    Buffer *mBuf = NULLP;
131
132    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
133       return RFAILED;
134    }
135
136 #ifdef MS_MBUF_CORRUPTION 
137    MS_BUF_ADD_ALLOC_CALLER();
138 #endif 
139    if(SAddPstMsgMult((Data *)boRpt, sizeof(RgInfDedBoRpt), mBuf) != ROK)
140    {
141       RGSCHINF_FREE_MSG(mBuf);
142       return RFAILED;
143    }
144
145    pst->event = (Event) EVTINFDEDBOUPDTREQ;
146    return (SPstTsk(pst,mBuf));
147 }
148
149
150 /**
151 * @brief Request from RLC to MAC for forwarding SDUs on 
152  * dedicated channel for transmission.
153 *
154 * @details
155 *
156 *     Function : cmUnpkMacSchDedBoUpdtReq
157 *
158 *  @param[in]   Pst*  pst
159 *  @param[in]   SpId  spId
160 *  @param[in]   RguDDatReqInfo  *  datReq
161 *  @return   S16
162 *      -# ROK
163 **/
164 S16 cmUnpkMacSchDedBoUpdtReq(DedBoUpdtReq func,Pst *pst,Buffer *mBuf)
165 {
166    RgInfDedBoRpt boRpt;
167    
168    if(SRemPreMsgMult((Data *)&boRpt, sizeof(RgInfDedBoRpt), mBuf) != ROK)
169    {
170       RGSCHINF_FREE_MSG(mBuf);
171       return RFAILED;
172    }
173
174    RGSCHINF_FREE_MSG(mBuf);
175    return ((*func)(pst, &boRpt));
176 }
177 /**
178 * @brief Request from RLC to MAC for forwarding SDUs on 
179  * dedicated channel for transmission.
180 *
181 * @details
182 *
183 *     Function : cmPkMacSchCmnBoUpdtReq
184 *
185 *  @param[in]   Pst*  pst
186 *  @param[in]   SpId  spId
187 *  @param[in]   RguDDatReqInfo  *  datReq
188 *  @return   S16
189 *      -# ROK
190 **/
191 S16 cmPkMacSchCmnBoUpdtReq(Pst* pst,RgInfCmnBoRpt* boRpt)
192 {
193    Buffer *mBuf = NULLP;
194
195    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
196       return RFAILED;
197    }
198
199 #ifdef MS_MBUF_CORRUPTION 
200    MS_BUF_ADD_ALLOC_CALLER();
201 #endif 
202    if(SAddPstMsgMult((Data *)boRpt, sizeof(RgInfCmnBoRpt), mBuf) != ROK)
203    {
204       RGSCHINF_FREE_MSG(mBuf);
205       return RFAILED;
206    }
207
208    pst->event = (Event) EVTINFCMNBOUPDTREQ;
209    return (SPstTsk(pst,mBuf));
210 }
211
212
213 /**
214 * @brief Request from RLC to MAC for forwarding SDUs on 
215  * dedicated channel for transmission.
216 *
217 * @details
218 *
219 *     Function : cmUnpkMacSchCmnBoUpdtReq
220 *
221 *  @param[in]   Pst*  pst
222 *  @param[in]   SpId  spId
223 *  @param[in]   RguDDatReqInfo  *  datReq
224 *  @return   S16
225 *      -# ROK
226 **/
227 S16 cmUnpkMacSchCmnBoUpdtReq(CmnBoUpdtReq func,Pst *pst,Buffer *mBuf)
228 {
229    RgInfCmnBoRpt boRpt;
230    
231    if(SRemPreMsgMult((Data *)&boRpt, sizeof(RgInfCmnBoRpt), mBuf) != ROK)
232    {
233       RGSCHINF_FREE_MSG(mBuf);
234       return RFAILED;
235    }
236
237    RGSCHINF_FREE_MSG(mBuf);
238    return ((*func)(pst, &boRpt));
239 }
240 /**
241 * @brief Request from RLC to MAC for forwarding SDUs on 
242  * dedicated channel for transmission.
243 *
244 * @details
245 *
246 *     Function : cmPkMacSchSfRecpInd
247 *
248 *  @param[in]   Pst*  pst
249 *  @param[in]   SpId  spId
250 *  @param[in]   RguDDatReqInfo  *  datReq
251 *  @return   S16
252 *      -# ROK
253 **/
254 S16 cmPkMacSchSfRecpInd(Pst* pst,RgInfSfDatInd*  datInd)
255 {
256    Buffer *mBuf = NULLP;
257
258    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
259       return RFAILED;
260    }
261
262    if(oduPackPointer((PTR)datInd, mBuf) != ROK)
263    {
264       RGSCHINF_FREE_MSG(mBuf);
265       return RFAILED;
266    }
267
268    pst->event = (Event) EVTINFSFRECPIND;
269    return (SPstTsk(pst,mBuf));
270 }
271
272
273 /**
274 * @brief Request from RLC to MAC for forwarding SDUs on 
275  * dedicated channel for transmission.
276 *
277 * @details
278 *
279 *     Function : cmUnpkMacSchSfRecpInd
280 *
281 *  @param[in]   Pst*  pst
282 *  @param[in]   SpId  spId
283 *  @param[in]   RguDDatReqInfo  *  datReq
284 *  @return   S16
285 *      -# ROK
286 **/
287 S16 cmUnpkMacSchSfRecpInd(SfRecpInd func,Pst *pst,Buffer *mBuf)
288 {
289    RgInfSfDatInd* datInd;
290    
291    if(oduUnpackPointer((PTR *)&datInd, mBuf) != ROK)
292    {
293       RGSCHINF_FREE_MSG(mBuf);
294       return RFAILED;
295    }
296
297    RGSCHINF_FREE_MSG(mBuf);
298    /* Call cmFreeMem(datInd) in scheduler */
299    return ((*func)(pst, datInd));
300 }
301
302 #ifdef LTEMAC_SPS
303 /**
304 * @brief Primitive from MAC to SCH to indicate release of UL SPS for a UE
305 *
306 * @details
307 *
308 *     Function : cmPkMacSchSpsRelInd
309 *
310 *  @param[in]   Pst*                 pst
311 *  @param[in]   RgInfSpsRelInfo*     relInfo
312 *  @return   S16
313 *      -# ROK
314 **/
315 S16 cmPkMacSchSpsRelInd(Pst* pst,RgInfSpsRelInfo* relInfo)
316 {
317    Buffer *mBuf = NULLP;
318
319    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
320       return RFAILED;
321    }
322
323    if(oduPackPointer((PTR)relInfo, mBuf) != ROK)
324    {
325       RGSCHINF_FREE_MSG(mBuf);
326       return RFAILED;
327    }
328
329    pst->event = (Event) EVTINFSPSRELIND;
330    return (SPstTsk(pst,mBuf));
331 } /* end of cmPkMacSchSpsRelInd */
332
333 /**
334 * @brief Primitive from MAC to SCH to indicate release of UL SPS for a UE
335 *
336 * @details
337 *
338 *     Function : cmUnpkMacSchSpsRelInd
339 *
340 *  @param[in]    SpsRelInd            func
341 *  @param[in]    Pst*                 pst
342 *  @param[in]    Buffer               *mBuf
343 *  @return   S16
344 *      -# ROK
345 **/
346 S16 cmUnpkMacSchSpsRelInd(SpsRelInd func,Pst *pst,Buffer *mBuf)
347 {
348    RgInfSpsRelInfo *relInfo;
349    
350    if(oduUnpackPointer((PTR *)&relInfo, mBuf) != ROK)
351    {
352       RGSCHINF_FREE_MSG(mBuf);
353       return RFAILED;
354    }
355
356    RGSCHINF_FREE_MSG(mBuf);
357    return ((*func)(pst, relInfo));
358 } /* end of cmUnpkMacSchSpsRelInd */
359 #endif /* LTEMAC_SPS */
360
361 #endif
362 #ifdef LCRG
363 /**
364 * @brief Request from RLC to MAC for forwarding SDUs on 
365  * dedicated channel for transmission.
366 *
367 * @details
368 *
369 *     Function : cmPkSchMacSfAllocReq
370 *
371 *  @param[in]   Pst*  pst
372 *  @param[in]   SpId  spId
373 *  @param[in]   RguDDatReqInfo  *  datReq
374 *  @return   S16
375 *      -# ROK
376 **/
377 S16 cmPkSchMacSfAllocReq(Pst* pst,RgInfSfAlloc* resAllocReq)
378 {
379    Buffer *mBuf = NULLP;
380
381    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
382       return RFAILED;
383    }
384
385    if(oduPackPointer((PTR)resAllocReq, mBuf) != ROK)
386    {
387       RGSCHINF_FREE_MSG(mBuf);
388       return RFAILED;
389    }
390
391    pst->event = (Event) EVTINFSFALLOCREQ;
392    return (SPstTsk(pst,mBuf));
393 }
394
395
396 /**
397 * @brief Request from RLC to MAC for forwarding SDUs on 
398  * dedicated channel for transmission.
399 *
400 * @details
401 *
402 *     Function : cmUnpkSchMacSfAllocReq
403 *
404 *  @param[in]   Pst*  pst
405 *  @param[in]   SpId  spId
406 *  @param[in]   RguDDatReqInfo  *  datReq
407 *  @return   S16
408 *      -# ROK
409 **/
410 S16 cmUnpkSchMacSfAllocReq(SfAllocReq func,Pst *pst,Buffer *mBuf)
411 {
412    RgInfSfAlloc* resAllocReq;
413    
414    if(oduUnpackPointer((PTR *)&resAllocReq, mBuf) != ROK)
415    {
416       RGSCHINF_FREE_MSG(mBuf);
417       return RFAILED;
418    }
419
420    RGSCHINF_FREE_MSG(mBuf);
421    return ((*func)(pst, resAllocReq));
422 }
423 /**
424 * @brief Request from  SCH To MAC for harq entity reset
425 *
426 * @details
427 *
428 *     Function : cmPkSchMacRstHqEntReq
429 *
430 *  @param[in]   Pst*  pst
431 *  @param[in]   RgInfResetHqEnt *hqEntInfo
432 *  @return   S16
433 *      -# ROK
434 **/
435 S16 cmPkSchMacRstHqEntReq(Pst*  pst,RgInfResetHqEnt* hqEntInfo)
436 {
437    Buffer *mBuf = NULLP;
438
439    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
440       return RFAILED;
441    }
442
443    if(oduPackPointer((PTR)hqEntInfo, mBuf) != ROK)
444    {
445       RGSCHINF_FREE_MSG(mBuf);
446       return RFAILED;
447    }
448
449    pst->event = (Event) EVTINFHQENTRESET;
450    return (SPstTsk(pst,mBuf));
451 }
452
453 /**
454 * @brief Request from SCH to MAC for resetting the harqentity
455 *
456 * @details
457 *
458 *     Function : cmUnpkSchMacRstHqEntReq
459 *
460 *  @param[in]   Pst*  pst
461 *  @param[in]   RgInfResetHqEnt *hqEntInfo
462 *  @return   S16
463 *      -# ROK
464 **/
465 S16 cmUnpkSchMacRstHqEntReq(RstHqEntReq func,Pst *pst,Buffer *mBuf)
466 {
467    RgInfResetHqEnt* hqEntRstInfo;
468    
469    if(oduUnpackPointer((PTR *)&hqEntRstInfo, mBuf) != ROK)
470    {
471       RGSCHINF_FREE_MSG(mBuf);
472       return RFAILED;
473    }
474
475    RGSCHINF_FREE_MSG(mBuf);
476    return ((*func)(pst, hqEntRstInfo));
477 }
478
479 /**
480 * @brief Request from RLC to MAC for forwarding SDUs on 
481  * dedicated channel for transmission.
482 *
483 * @details
484 *
485 *     Function : cmPkSchMacRlsHqReq
486 *
487 *  @param[in]   Pst*  pst
488 *  @param[in]   SpId  spId
489 *  @param[in]   RguDDatReqInfo  *  datReq
490 *  @return   S16
491 *      -# ROK
492 **/
493 S16 cmPkSchMacRlsHqReq(Pst* pst,RgInfRlsHqInfo* sfHqInfo)
494 {
495    Buffer *mBuf = NULLP;
496
497    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
498       return RFAILED;
499    }
500
501    if(oduPackPointer((PTR)sfHqInfo, mBuf) != ROK)
502    {
503       RGSCHINF_FREE_MSG(mBuf);
504       return RFAILED;
505    }
506
507    pst->event = (Event) EVTINFRLSHQREQ;
508    return (SPstTsk(pst,mBuf));
509 }
510
511 /**
512 * @brief Request from RLC to MAC for forwarding SDUs on 
513  * dedicated channel for transmission.
514 *
515 * @details
516 *
517 *     Function : cmUnpkSchMacRlsHqReq
518 *
519 *  @param[in]   Pst*  pst
520 *  @param[in]   SpId  spId
521 *  @param[in]   RguDDatReqInfo  *  datReq
522 *  @return   S16
523 *      -# ROK
524 **/
525 S16 cmUnpkSchMacRlsHqReq(RlsHqReq func,Pst *pst,Buffer *mBuf)
526 {
527    RgInfRlsHqInfo* sfHqInfo;
528    
529    if(oduUnpackPointer((PTR *)&sfHqInfo, mBuf) != ROK)
530    {
531       RGSCHINF_FREE_MSG(mBuf);
532       return RFAILED;
533    }
534
535    RGSCHINF_FREE_MSG(mBuf);
536    return ((*func)(pst, sfHqInfo));
537 }
538 /**
539 * @brief Request from RLC to MAC for forwarding SDUs on 
540  * dedicated channel for transmission.
541 *
542 * @details
543 *
544 *     Function : cmPkSchMacRlsRntiReq
545 *
546 *  @param[in]   Pst*  pst
547 *  @param[in]   SpId  spId
548 *  @param[in]   RguDDatReqInfo  *  datReq
549 *  @return   S16
550 *      -# ROK
551 **/
552 S16 cmPkSchMacRlsRntiReq(Pst* pst,RgInfRlsRnti* rlsRnti)
553 {
554    Buffer *mBuf = NULLP;
555
556    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
557       return RFAILED;
558    }
559
560 #ifdef MS_MBUF_CORRUPTION 
561    MS_BUF_ADD_ALLOC_CALLER();
562 #endif 
563    if(SAddPstMsgMult((Data *)rlsRnti, sizeof(RgInfRlsRnti), mBuf) != ROK)
564    {
565       RGSCHINF_FREE_MSG(mBuf);
566       return RFAILED;
567    }
568
569    pst->event = (Event) EVTINFRLSRNTIREQ;
570    return (SPstTsk(pst,mBuf));
571 }
572
573 /**
574 * @brief Request from RLC to MAC for forwarding SDUs on 
575  * dedicated channel for transmission.
576 *
577 * @details
578 *
579 *     Function : cmUnpkSchMacRlsRntiReq
580 *
581 *  @param[in]   Pst*  pst
582 *  @param[in]   SpId  spId
583 *  @param[in]   RguDDatReqInfo  *  datReq
584 *  @return   S16
585 *      -# ROK
586 **/
587 S16 cmUnpkSchMacRlsRntiReq(RlsRntiReq func,Pst *pst,Buffer *mBuf)
588 {
589    RgInfRlsRnti rlsRnti;
590    
591    if(SRemPreMsgMult((Data *)&rlsRnti, sizeof(RgInfRlsRnti), mBuf) != ROK)
592    {
593       RGSCHINF_FREE_MSG(mBuf);
594       return RFAILED;
595    }
596
597    RGSCHINF_FREE_MSG(mBuf);
598    return ((*func)(pst, &rlsRnti));
599 }
600
601 /**
602 * @brief Request from RLC to MAC for forwarding SDUs on 
603  * dedicated channel for transmission.
604 *
605 * @details
606 *
607 *     Function : cmPkSchMacCellRegReq
608 *
609 *  @param[in]   Pst*  pst
610 *  @param[in]   SpId  spId
611 *  @param[in]   RguDDatReqInfo  *  datReq
612 *  @return   S16
613 *      -# ROK
614 **/
615 S16 cmPkSchMacCellRegReq(Pst* pst,RgInfCellReg* regReq)
616 {
617    Buffer *mBuf = NULLP;
618
619    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
620       return RFAILED;
621    }
622
623 #ifdef MS_MBUF_CORRUPTION 
624    MS_BUF_ADD_ALLOC_CALLER();
625 #endif 
626    if(SAddPstMsgMult((Data *)regReq, sizeof(RgInfCellReg), mBuf) != ROK)
627    {
628       RGSCHINF_FREE_MSG(mBuf);
629       return RFAILED;
630    }
631
632    pst->event = (Event) EVTINFCELLREGREQ;
633    return (SPstTsk(pst,mBuf));
634 }
635
636 /**
637 * @brief Request from RLC to MAC for forwarding SDUs on 
638  * dedicated channel for transmission.
639 *
640 * @details
641 *
642 *     Function : cmUnpkSchMacCellRegReq
643 *
644 *  @param[in]   Pst*  pst
645 *  @param[in]   SpId  spId
646 *  @param[in]   RguDDatReqInfo  *  datReq
647 *  @return   S16
648 *      -# ROK
649 **/
650 S16 cmUnpkSchMacCellRegReq(CellRegReq func,Pst *pst,Buffer *mBuf)
651 {
652    RgInfCellReg regReq;
653    
654    if(SRemPreMsgMult((Data *)&regReq, sizeof(RgInfCellReg), mBuf) != ROK)
655    {
656       RGSCHINF_FREE_MSG(mBuf);
657       return RFAILED;
658    }
659
660    RGSCHINF_FREE_MSG(mBuf);
661    return ((*func)(pst, &regReq));
662 }
663
664 /**
665 * @brief Primitive from SCH to MAC to register GBR LCG per UE
666 *
667 * @details
668 *
669 *     Function : cmPkSchMacLcgRegReq
670 *
671 *  @param[in]   Pst*                 pst
672 *  @param[in]   RgInfLcgRegReq       *lcgRegReq
673 *  @return   S16
674 *      -# ROK
675 **/
676 S16 cmPkSchMacLcgRegReq(Pst* pst,RgInfLcgRegReq *lcgRegReq)
677 {
678    Buffer *mBuf = NULLP;
679
680    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
681       return RFAILED;
682    }
683
684    if(SAddPstMsgMult((Data *)lcgRegReq, sizeof(RgInfLcgRegReq), mBuf) != ROK)
685    {
686       RGSCHINF_FREE_MSG(mBuf);
687       return RFAILED;
688    }
689
690    pst->event = (Event) EVTINFLCGREG;
691    return (SPstTsk(pst,mBuf));
692 } /* end of cmPkSchMacLcgRegReq */
693
694 /**
695 * @brief Primitive from SCH to MAC to register GBR LCG
696 *
697 * @details
698 *
699 *     Function : cmUnpkSchMacLcgRegReq
700 *
701 *  @param[in]    LcgReg               func
702 *  @param[in]    Pst*                 pst
703 *  @param[in]    Buffer               *mBuf
704 *  @return   S16
705 *      -# ROK
706 **/
707 S16 cmUnpkSchMacLcgRegReq(LcgReg func,Pst *pst,Buffer *mBuf)
708 {
709    RgInfLcgRegReq       *lcgRegReq;
710    
711    if(oduUnpackPointer((PTR *)&lcgRegReq, mBuf) != ROK)
712    {
713       RGSCHINF_FREE_MSG(mBuf);
714       return RFAILED;
715    }
716
717    RGSCHINF_FREE_MSG(mBuf);
718    return ((*func)(pst, lcgRegReq));
719 } /* end of cmUnpkSchMacLcgRegReq */
720
721 #ifdef LTEMAC_SPS
722
723 /**
724 * @brief Primitive from SCH to MAC to register the set of SPS LCs per UE
725 *
726 * @details
727 *
728 *     Function : cmPkSchMacSpsLcRegReq
729 *
730 *  @param[in]   Pst*                 pst
731 *  @param[in]   RgInfSpsLcInfo       *lcInfo
732 *  @return   S16
733 *      -# ROK
734 **/
735 S16 cmPkSchMacSpsLcRegReq(Pst*  pst,RgInfSpsLcInfo *lcInfo)
736 {
737    Buffer *mBuf = NULLP;
738
739    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
740       return RFAILED;
741    }
742
743    if(oduPackPointer((PTR)lcInfo, mBuf) != ROK)
744    {
745       RGSCHINF_FREE_MSG(mBuf);
746       return RFAILED;
747    }
748
749    pst->event = (Event) EVTINFSPSLCREG;
750    return (SPstTsk(pst,mBuf));
751 } /* end of cmPkSchMacSpsLcRegReq */
752
753 /**
754 * @brief Primitive from SCH to MAC to reset SPS Params for the UE
755 *
756 * @details
757 *
758 *     Function : cmPkSchMacUlSpsResetReq
759 *
760 *  @param[in]   Pst*                 pst
761 *  @param[in]   RgInfUlSpsReset       *ulSpsResetInfo
762 *  @return   S16
763 *      -# ROK
764 **/
765 S16 cmPkSchMacUlSpsResetReq(Pst*  pst,RgInfUlSpsReset  *ulSpsResetInfo)
766 {
767    Buffer *mBuf = NULLP;
768
769    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
770       return RFAILED;
771    }
772
773    if(oduPackPointer((PTR)ulSpsResetInfo, mBuf) != ROK)
774    {
775       RGSCHINF_FREE_MSG(mBuf);
776       return RFAILED;
777    }
778
779    pst->event = (Event) EVTINFSPSRESET;
780    return (SPstTsk(pst,mBuf));
781 } /* end of cmPkSchMacUlSpsResetReq */
782
783 /**
784 * @brief Primitive from SCH to MAC to register the set of SPS LCs per UE
785 *
786 * @details
787 *
788 *     Function : cmUnpkSchMacSpsLcRegReq
789 *
790 *  @param[in]    SpsLcReg             func
791 *  @param[in]    Pst*                 pst
792 *  @param[in]    Buffer               *mBuf
793 *  @return   S16
794 *      -# ROK
795 **/
796 S16 cmUnpkSchMacSpsLcRegReq(SpsLcReg func,Pst *pst,Buffer *mBuf)
797 {
798    RgInfSpsLcInfo       *lcInfo;
799    
800    if(oduUnpackPointer((PTR *)&lcInfo, mBuf) != ROK)
801    {
802       RGSCHINF_FREE_MSG(mBuf);
803       return RFAILED;
804    }
805
806    RGSCHINF_FREE_MSG(mBuf);
807    return ((*func)(pst, lcInfo));
808 } /* end of cmUnpkSchMacSpsLcRegReq */
809
810
811
812 /**
813 * @brief Primitive from SCH to MAC to reset UL SPS params
814 *
815 * @details
816 *
817 *     Function : cmUnpkSchMacUlSpsResetReq
818 *
819 *  @param[in]    UlSpsReset             func
820 *  @param[in]    Pst*                 pst
821 *  @param[in]    Buffer               *mBuf
822 *  @return   S16
823 *      -# ROK
824 **/
825 S16 cmUnpkSchMacUlSpsResetReq(UlSpsReset func,Pst *pst,Buffer  *mBuf)
826 {
827    RgInfUlSpsReset       *ulSpsResetInfo;
828    
829    if(oduUnpackPointer((PTR *)&ulSpsResetInfo, mBuf) != ROK)
830    {
831       RGSCHINF_FREE_MSG(mBuf);
832       return RFAILED;
833    }
834
835    RGSCHINF_FREE_MSG(mBuf);
836    return ((*func)(pst, ulSpsResetInfo));
837 } /* end of cmUnpkSchMacUlSpsResetReq */
838
839
840
841 /**
842 * @brief Primitive from SCH to MAC to deregister the set of SPS LCs per UE
843 *
844 * @details
845 *
846 *     Function : cmPkSchMacSpsLcDeregReq
847 *
848 *  @param[in]   Pst*                 pst
849 *  @param[in]   CmLteCellId          cellId,
850 *  @param[in]   CmLteRnti            crnti
851 *  @return   S16
852 *      -# ROK
853 **/
854 S16 cmPkSchMacSpsLcDeregReq(Pst* pst,CmLteCellId cellId,CmLteRnti  crnti)
855 {
856    Buffer *mBuf = NULLP;
857
858    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
859       return RFAILED;
860    }
861
862    CMCHKPK(cmPkLteCellId, cellId, mBuf);
863    CMCHKPK(cmPkLteRnti, crnti, mBuf);
864
865    pst->event = (Event) EVTINFSPSLCDEREG;
866    return (SPstTsk(pst,mBuf));
867 } /* end of cmPkSchMacSpsLcDeregReq */
868
869 /**
870 * @brief Primitive from SCH to MAC to deregister the set of SPS LCs per UE
871 *
872 * @details
873 *
874 *     Function : cmUnpkSchMacSpsLcDeregReq
875 *
876 *  @param[in]    SpsLcDereg           func
877 *  @param[in]    Pst*                 pst
878 *  @param[in]    Buffer               *mBuf
879 *  @return   S16
880 *      -# ROK
881 **/
882 S16 cmUnpkSchMacSpsLcDeregReq(SpsLcDereg func,Pst  *pst, Buffer *mBuf)
883 {
884    CmLteCellId  cellId;
885    CmLteRnti    crnti;
886    
887    CMCHKUNPK(cmUnpkLteRnti, &crnti, mBuf);
888    CMCHKUNPK(cmUnpkLteCellId, &cellId, mBuf);
889
890    RGSCHINF_FREE_MSG(mBuf);
891    return ((*func)(pst, cellId, crnti));
892 } /* end of cmUnpkSchMacSpsLcDeregReq */
893
894 #endif /* LTEMAC_SPS */
895 #ifdef LTE_L2_MEAS
896
897 /**
898 * @brief Primitive from SCH to MAC for L2 Measurement
899 *
900 * @details
901 *
902 *     Function : cmPkSchMacL2MeasReq
903 *
904 *  @param[in]   Pst*                 pst
905 *  @param[in]   RgInfSpsLcInfo       *lcInfo
906 *  @return   S16
907 *      -# ROK
908 **/
909 S16 cmPkSchMacL2MeasReq(Pst* pst,RgInfL2MeasReq  *measInfo)
910 {
911    Buffer *mBuf = NULLP;
912
913    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
914       return RFAILED;
915    }
916    if(SAddPstMsgMult((Data *)measInfo, sizeof(RgInfL2MeasReq), mBuf) != ROK)
917    {
918       RGSCHINF_FREE_MSG(mBuf);
919       return RFAILED;
920    }
921
922    pst->event = (Event) EVTINFL2MEASREQ;
923    return (SPstTsk(pst,mBuf));
924 } /* end of cmPkSchMacL2MeasReq */
925
926 /**
927 * @brief Primitive from SCH to MAC for L2 Stop Measurement
928 *
929 * @details
930 *
931 *     Function : cmPkSchMacL2MeasStopReq
932 *
933 *  @param[in]   Pst*                 pst
934 *  @param[in]   RgInfSpsLcInfo       *lcInfo
935 *  @return   S16
936 *      -# ROK
937 **/
938 S16 cmPkSchMacL2MeasStopReq(Pst*  pst,RgInfL2MeasStopReq *measInfo)
939 {
940    Buffer *mBuf = NULLP;
941
942    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
943        return RFAILED;
944   }
945    if(SAddPstMsgMult((Data *)measInfo, sizeof(RgInfL2MeasStopReq), mBuf) != ROK)
946    {
947       ODU_PUT_MSG_BUF(mBuf);
948       return RFAILED;
949    }
950
951    pst->event = (Event) EVTINFL2MEASSTOPREQ;
952    return (SPstTsk(pst,mBuf));
953 } /* end of cmPkSchMacL2MeasStopReq */
954 /**
955 * @brief Primitive from SCH to MAC for L2 Measurement
956 *         Send Request
957 * @details
958 *
959 *     Function : cmPkSchMacL2MeasSendReq
960 *
961 *  @param[in]   Pst*                 pst
962 *  @param[in]   RgInfSpsLcInfo       *lcInfo
963 *  @return   S16
964 *      -# ROK
965 **/
966 S16 cmPkSchMacL2MeasSendReq(Pst* pst,RgInfL2MeasSndReq *measInfo)
967 {
968    Buffer *mBuf = NULLP;
969
970    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
971        return RFAILED;
972   }
973
974    if(SAddPstMsgMult((Data *)measInfo, sizeof(RgInfL2MeasSndReq), mBuf) != ROK)
975    {
976       ODU_PUT_MSG_BUF(mBuf);
977       return RFAILED;
978    }
979
980    pst->event = (Event) EVTINFL2MEASSENDREQ;
981    return (SPstTsk(pst,mBuf));
982 } /* end of cmPkSchMacL2MeasSendReq */
983
984 /**
985 * @brief Primitive from SCH to MAC for L2 Measurement request
986 *
987 * @details
988 *
989 *     Function : cmUnpkSchMacL2MeasReq
990 *
991 *  @param[in]    L2MeasReg            func
992 *  @param[in]    Pst*                 pst
993 *  @param[in]    Buffer               *mBuf
994 *  @return   S16
995 *      -# ROK
996 **/
997 S16 cmUnpkSchMacL2MeasReq(L2MeasReq func,Pst *pst,Buffer *mBuf)
998 {
999    RgInfL2MeasReq      measInfo;
1000    
1001    if(SRemPreMsgMult((Data *)&measInfo, sizeof(RgInfL2MeasReq), mBuf) != ROK)
1002    {
1003       RGSCHINF_FREE_MSG(mBuf);
1004       return RFAILED;
1005    }
1006
1007    RGSCHINF_FREE_MSG(mBuf);
1008    return ((*func)(pst, &measInfo));
1009 } /* end of cmUnpkSchMacL2MeasReq */
1010
1011 /**
1012 * @brief Primitive from SCH to MAC for L2 Measurement Stop request
1013 *
1014 * @details
1015 *
1016 *     Function : cmUnpkSchMacL2MeasStopReq
1017 *
1018 *  @param[in]    L2MeasReg            func
1019 *  @param[in]    Pst*                 pst
1020 *  @param[in]    Buffer               *mBuf
1021 *  @return   S16
1022 *      -# ROK
1023 **/
1024 S16 cmUnpkSchMacL2MeasStopReq(L2MeasStopReq func,Pst *pst,Buffer *mBuf)
1025 {
1026    RgInfL2MeasStopReq measInfo;
1027
1028    if(SRemPreMsgMult((Data *)&measInfo, sizeof(RgInfL2MeasStopReq), mBuf) != ROK)
1029    {
1030       ODU_PUT_MSG_BUF(mBuf);
1031       return RFAILED;
1032    }
1033
1034    ODU_PUT_MSG_BUF(mBuf);
1035    return ((*func)(pst, &measInfo));
1036 } /* end of cmUnpkSchMacL2MeasReq */
1037 /**
1038 * @brief Primitive from SCH to MAC for L2 Measurement request
1039 *
1040 * @details
1041 *
1042 *     Function : cmUnpkSchMacL2MeasReq
1043 *
1044 *  @param[in]    L2MeasReg            func
1045 *  @param[in]    Pst*                 pst
1046 *  @param[in]    Buffer               *mBuf
1047 *  @return   S16
1048 *      -# ROK
1049 **/
1050 S16 cmUnpkSchMacL2MeasSendReq(L2MeasSendReq  func,Pst *pst,Buffer *mBuf)
1051 {
1052    RgInfL2MeasSndReq measInfo;
1053
1054  if(SRemPreMsgMult((Data *)&measInfo, sizeof(RgInfL2MeasSndReq), mBuf) != ROK)  
1055    {
1056       ODU_PUT_MSG_BUF(mBuf);
1057       return RFAILED;
1058    }
1059
1060    ODU_PUT_MSG_BUF(mBuf);
1061    return ((*func)(pst, &measInfo));
1062 } /* end of cmUnpkSchMacL2MeasSendReq*/
1063
1064 /**
1065 * @brief Primitive from MAC to SCH for L2 Measurement
1066 *
1067 * @details
1068 *
1069 *     Function : cmPkMacSchL2MeasCfm
1070 *
1071 *  @param[in]   Pst*                 pst
1072 *  @param[in]   RgInfL2MeasCfm       *measInfo
1073 *  @return   S16
1074 *      -# ROK
1075 **/
1076 S16 cmPkMacSchL2MeasCfm(Pst*  pst,RgInfL2MeasCfm *measCfm)
1077 {
1078    Buffer *mBuf = NULLP;
1079
1080    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
1081       return RFAILED;
1082    }
1083
1084    if(SAddPstMsgMult((Data *)measCfm, sizeof(RgInfL2MeasCfm), mBuf) != ROK)
1085    {
1086       RGSCHINF_FREE_MSG(mBuf);
1087       return RFAILED;
1088    }
1089
1090    pst->event = (Event) EVTINFL2MEASCFM;
1091    return (SPstTsk(pst,mBuf));
1092 } /* end of cmPkMacSchL2MeasCfm */
1093
1094
1095 /**
1096 * @brief Primitive from MAC to SCH for L2 Measurement
1097 *        stop cfm
1098 * @details
1099 *
1100 *     Function : cmPkMacSchL2MeasStopCfm
1101 *
1102 *  @param[in]   Pst*                 pst
1103 *  @param[in]   RgInfL2MeasCfm       *measInfo
1104 *  @return   S16
1105 *      -# ROK
1106 **/
1107 S16 cmPkMacSchL2MeasStopCfm(Pst*  pst,RgInfL2MeasCfm  *measCfm)
1108 {
1109    Buffer *mBuf = NULLP;
1110
1111  if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) {
1112       return RFAILED;
1113    }
1114
1115    if(SAddPstMsgMult((Data *)measCfm, sizeof(RgInfL2MeasCfm), mBuf) != ROK)
1116    {
1117       ODU_PUT_MSG_BUF(mBuf);
1118       return RFAILED;
1119    }
1120
1121    pst->event = (Event) EVTINFL2MEASSTOPCFM;
1122    return (SPstTsk(pst,mBuf));
1123 }/*cmPkMacSchL2MeasStopCfm*/
1124 /**
1125 * @brief Primitive from MAC to SCH for L2 Measurement Cfm
1126 *
1127 * @details
1128 *
1129 *     Function : cmUnpkSchMacL2MeasReq
1130 *
1131 *  @param[in]    L2MeasCfm            func
1132 *  @param[in]    Pst*                 pst
1133 *  @param[in]    Buffer               *mBuf
1134 *  @return   S16
1135 *      -# ROK
1136 **/
1137 S16 cmUnpkMacSchL2MeasCfm(L2MeasCfm func,Pst *pst,Buffer *mBuf)
1138 {
1139    RgInfL2MeasCfm      measCfm;
1140    
1141    if(SRemPreMsgMult((Data *)&measCfm, sizeof(RgInfL2MeasCfm), mBuf) != ROK)
1142    {
1143       RGSCHINF_FREE_MSG(mBuf);
1144       return RFAILED;
1145    }
1146
1147    RGSCHINF_FREE_MSG(mBuf);
1148    return ((*func)(pst, &measCfm));
1149 } /* end of cmUnpkMacSchL2MeasCfm */
1150
1151 /**
1152 * @brief Primitive from MAC to SCH for L2 Measurement Stop  Cfm
1153 *
1154 * @details
1155 *
1156 *     Function : cmUnpkMacSchL2MeasStopCfm
1157 *
1158 *  @param[in]    L2MeasCfm            func
1159 *  @param[in]    Pst*                 pst
1160 *  @param[in]    Buffer               *mBuf
1161 *  @return   S16
1162 *      -# ROK
1163 **/
1164 S16 cmUnpkMacSchL2MeasStopCfm(L2MeasCfm func,Pst *pst,Buffer  *mBuf)
1165 {
1166    RgInfL2MeasCfm      measCfm;
1167
1168    if(SRemPreMsgMult((Data *)&measCfm, sizeof(RgInfL2MeasCfm), mBuf) != ROK)
1169    {
1170       ODU_PUT_MSG_BUF(mBuf);
1171       return RFAILED;
1172    }
1173
1174    ODU_PUT_MSG_BUF(mBuf);
1175    return ((*func)(pst, &measCfm));
1176 } /* end of cmUnpkMacSchL2MeasStopCfm */
1177
1178 #endif/* LTE_L2_MEAS */
1179
1180 #endif
1181
1182
1183 /**********************************************************************
1184  
1185          End of file
1186 **********************************************************************/