Moving all common header file into common_def.h file
[o-du/l2.git] / src / 5gnrmac / rg_prg.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 MAC to MAC interface
26                primitives.
27   
28      File:     rg_prg.c 
29   
30 **********************************************************************/
31 /* header include files -- defines (.h) */
32 #include "common_def.h"
33 #include "lrg.h"
34 #include "crg.h"
35 #include "rgu.h"
36 #include "tfu.h"
37 #include "rg_sch_inf.h"
38 #include "rg_prg.h"
39 #include "rg_env.h"
40 #include "rg.h"
41 #include "rg_err.h"
42
43 /* header/extern include files (.x) */
44 #include "rgu.x"           /* RGU types */
45 #include "tfu.x"           /* RGU types */
46 #include "lrg.x"           /* layer management typedefs for MAC */
47 #include "crg.x"           /* layer management typedefs for MAC */
48 #include "rg_sch_inf.x"           /* layer management typedefs for MAC */
49 #include "rg_prg.x"           /* Prg(MAC-MAC)interface includes */
50 #include "du_app_mac_inf.h"
51 #include "rg.x"            /* typedefs for MAC */
52
53 #ifdef LTE_ADV
54 #ifdef LCPRG
55 /** 
56  * @brief Ue SCell Cfg Req from PMac to SMac.
57  * @details This primitive is used for light-weight loose coupling.
58  *
59  * @details
60  *
61  *     Function : cmPkPrgPMacSMacUeSCellCfgReq
62  *
63  *  @param[in]   Pst*  pst
64  *  @param[in]   RgPrgUeSCellCfgInfo   *ueSCellCfgInfo
65  *  @return   S16
66  *      -# ROK
67  **/
68 #ifdef ANSI
69 PUBLIC S16 cmPkPrgPMacSMacUeSCellCfgReq
70 (
71 Pst           *pst,
72 RgPrgUeSCellCfgInfo   *ueSCellCfgInfo
73 )
74 #else
75 PUBLIC S16 cmPkPrgPMacSMacUeSCellCfgReq(pst, ueSCellCfgInfo)
76 Pst            *pst;
77 RgPrgUeSCellCfgInfo    *ueSCellCfgInfo;
78 #endif
79 {
80    Buffer *mBuf = NULLP;
81
82    TRC2(cmPkPrgPMacSMacUeSCellCfgReq)
83
84    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
85    {
86       RETVALUE(RFAILED);
87    }
88    
89    if(SAddPstMsgMult((Data *)ueSCellCfgInfo, sizeof(RgPrgUeSCellCfgInfo),\
90             mBuf) != ROK)
91    {
92       RGPRG_FREE_MSG(mBuf);
93       RETVALUE(RFAILED);
94    }
95
96    pst->event = (Event) EVTPRGUESCELLCFGREQ;
97    RETVALUE(SPstTsk(pst,mBuf));
98 }
99
100 /** 
101  * @brief Ue SCell Cfg Req from PMac to SMac.
102  * @details This primitive is used for light-weight loose coupling.
103  *
104  * @details
105  *
106  *     Function : cmUnpkPrgPMacSMacUeSCellCfgReq
107  *
108  *  @param[in]   Pst*  pst
109  *  @param[in]   RgPrgUeSCellCfgInfo   *ueSCellCfgInfo
110  *  @return   S16
111  *      -# ROK
112  **/
113 #ifdef ANSI
114 PUBLIC S16 cmUnpkPrgPMacSMacUeSCellCfgReq
115 (
116 RgPrgUeSCellCfgReq   func,
117 Pst                  *pst,
118 Buffer               *mBuf
119 )
120 #else
121 PUBLIC S16 cmUnpkPrgPMacSMacUeSCellCfgReq(func, pst, mBuf)
122 RgPrgUeSCellCfgReq   func;
123 Pst                  *pst;
124 Buffer               *mBuf;
125 #endif
126 {
127    RgPrgUeSCellCfgInfo    ueSCellCfgInfo;
128    
129    TRC2(cmUnpkPrgPMacSMacUeSCellCfgReq)
130
131    if(SRemPreMsgMult((Data *)&ueSCellCfgInfo, sizeof(RgPrgUeSCellCfgInfo), mBuf) != ROK)
132    {
133       RGPRG_FREE_MSG(mBuf);
134       RETVALUE(RFAILED);
135    }
136
137    RGPRG_FREE_MSG(mBuf);
138    RETVALUE((*func)(pst, &ueSCellCfgInfo));
139 }
140
141 /** 
142  * @brief Config confirm for Ue SCell config Req.
143  * @details This primitive is used for light-weight loose coupling.
144  *
145  * @details
146  *
147  *     Function : cmPkPrgSMacPMacCfgCfm
148  *
149  *  @param[in]   Pst              *pst
150  *  @param[in]   RgPrgCfgCfmInfo  *cfgCfm
151  *  @return   S16
152  *      -# ROK
153  **/
154 #ifdef ANSI
155 PUBLIC S16 cmPkPrgSMacPMacCfgCfm
156 (
157 Pst               *pst,
158 RgPrgCfgCfmInfo   *cfgCfm
159 )
160 #else
161 PUBLIC S16 cmPkPrgSMacPMacCfgCfm(pst, cfgCfm)
162 Pst                *pst;
163 RgPrgCfgCfmInfo    *cfgCfm;
164 #endif
165 {
166    Buffer *mBuf = NULLP;
167
168    TRC2(cmPkPrgSMacPMacCfgCfm)
169
170    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
171    {
172       RETVALUE(RFAILED);
173    }
174    
175    if(SAddPstMsgMult((Data *)cfgCfm, sizeof(RgPrgCfgCfmInfo), mBuf) != ROK)
176    {
177       RGPRG_FREE_MSG(mBuf);
178       RETVALUE(RFAILED);
179    }
180    switch(cfgCfm->event)
181    {
182       case EVTPRGUESCELLLCHMODCFM : /*cfm for Lch recfg */ 
183       {
184          pst->event = (Event) EVTPRGUESCELLLCHMODCFM;
185       }
186       break;
187       case EVTPRGUESCELLCFGCFM : /*cfm for Adding Scell */ 
188       {
189          pst->event = (Event) EVTPRGUESCELLCFGCFM;
190       }
191       break;
192       case EVTPRGUESCELLLCHDELCFM : /* cfm for deleting Lch */
193       {
194          pst->event = (Event) EVTPRGUESCELLLCHDELCFM;
195       }
196       break;
197       case EVTPRGUESCELLLCHADDCFM: /* cfm for adding of LCh */
198       {
199          pst->event = (Event) EVTPRGUESCELLLCHADDCFM;
200       }
201       break;
202    }
203    RETVALUE(SPstTsk(pst,mBuf));
204 }
205
206 /** 
207  * @brief Config confirm for SCell addd Req.
208  * @details This primitive is used for light-weight loose coupling.
209  *
210  * @details
211  *
212  *     Function : cmUnpkPrgSMacPMacCfgCfm
213  *
214  *  @param[in]   CfgCfm          fun
215  *  @param[in]   Pst*            pst
216  *  @param[in]   RgPrgCfgCfmInfo *cfgCfm
217  *  @return   S16
218  *      -# ROK
219  **/
220 #ifdef ANSI
221 PUBLIC S16 cmUnpkPrgSMacPMacCfgCfm
222 (
223 RgSMacPMacCfgCfm    func,
224 Pst                 *pst,
225 Buffer              *mBuf
226 )
227 #else
228 PUBLIC S16 cmUnpkPrgSMacPMacCfgCfm(func, pst, mBuf)
229 RgSMacPMacCfgCfm    func;
230 Pst                 *pst;
231 Buffer              *mBuf;
232 #endif
233 {
234    RgPrgCfgCfmInfo   cfgCfm;
235    
236    TRC2(cmUnpkPrgSMacPMacCfgCfm)
237
238    if(SRemPreMsgMult((Data *)&cfgCfm, sizeof(RgPrgCfgCfmInfo), mBuf) != ROK)
239    {
240       RGPRG_FREE_MSG(mBuf);
241       RETVALUE(RFAILED);
242    }
243
244    RGPRG_FREE_MSG(mBuf);
245    RETVALUE((*func)(pst, &cfgCfm));
246 }
247
248 /** 
249  * @brief SCell Ue Delete Req/UeId change req from PMac to SMac.
250  * @details This primitive is used for light-weight loose coupling.
251  *
252  * @details
253  *
254  *     Function : cmPkPrgPMacSMacUeSCellDelReq
255  *
256  *  @param[in]   Pst                  *pst
257  *  @param[in]   RgPrgUeSCellDelInfo  *ueSCellDelInfo
258  *  @return   S16
259  *      -# ROK
260  **/
261 #ifdef ANSI
262 PUBLIC S16 cmPkPrgPMacSMacUeSCellDelReq
263 (
264 Pst                   *pst,
265 RgPrgUeSCellDelInfo   *ueSCellDelInfo
266 )
267 #else
268 PUBLIC S16 cmPkPrgPMacSMacUeSCellDelReq(pst, ueSCellDelInfo)
269 Pst                    *pst;
270 RgPrgUeSCellDelInfo    *ueSCellDelInfo;
271 #endif
272 {
273    Buffer *mBuf = NULLP;
274
275    TRC2(cmPkPrgPMacSMacUeSCellDelReq)
276
277    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
278    {
279       RETVALUE(RFAILED);
280    }
281    
282    if(SAddPstMsgMult((Data *)ueSCellDelInfo, sizeof(RgPrgUeSCellDelInfo), mBuf)\
283          != ROK)
284    {
285       RGPRG_FREE_MSG(mBuf);
286       RETVALUE(RFAILED);
287    }
288
289    pst->event = (Event) EVTPRGUESCELLDELREQ;
290    RETVALUE(SPstTsk(pst,mBuf));
291 }
292
293 /** 
294  * @brief Unpacking for SCell UE delete/Ue Id Change Req to SMAC.
295  * @details This primitive is used for light-weight loose coupling.
296  *
297  * @details
298  *
299  *     Function : cmUnpkPrgPMacSMacUeSCellDelReq
300  *
301  *  @param[in]   CfgCfm        fun
302  *  @param[in]   Pst*          pst
303  *  @param[in]   Buffer        *mBuf
304  *  @return   S16
305  *      -# ROK
306  **/
307 #ifdef ANSI
308 PUBLIC S16 cmUnpkPrgPMacSMacUeSCellDelReq
309 (
310 RgUeSCellDelReq    func,
311 Pst                *pst,
312 Buffer             *mBuf
313 )
314 #else
315 PUBLIC S16 cmUnpkPrgPMacSMacUeSCellDelReq(func, pst, mBuf)
316 RgUeSCellDelReq  func;
317 Pst              *pst;
318 Buffer           *mBuf;
319 #endif
320 {
321   RgPrgUeSCellDelInfo ueSCellDelInfo;
322    
323    TRC2(cmUnpkPrgPMacSMacUeSCellDelReq)
324
325    if(SRemPreMsgMult((Data *)&ueSCellDelInfo, sizeof(RgPrgUeSCellDelInfo),\
326             mBuf) != ROK)
327    {
328       RGPRG_FREE_MSG(mBuf);
329       RETVALUE(RFAILED);
330    }
331
332    RGPRG_FREE_MSG(mBuf);
333    RETVALUE((*func)(pst, &ueSCellDelInfo));
334 }
335
336 /** 
337  * @brief Ue Lch Addition  Req from PMac to SMac.
338  * @details This primitive is used for light-weight loose coupling.
339  *
340  * @details
341  *
342  *     Function : cmPkPrgPMacSMacUeSCellLchAddReq
343  *
344  *  @param[in]   Pst*                      pst
345  *  @param[in]   RgPrgUeSCellLchAddInfo   *lchCfgInfo
346  *  @return   S16
347  *      -# ROK
348  **/
349 #ifdef ANSI
350 PUBLIC S16 cmPkPrgPMacSMacUeSCellLchAddReq
351 (
352 Pst                      *pst,
353 RgPrgUeSCellLchAddInfo   *lchCfgInfo,
354 )
355 #else
356 PUBLIC S16 cmPkPrgPMacSMacUeSCellLchAddReq(pst, lchCfgInfo)
357 Pst                       *pst;
358 RgPrgUeSCellLchAddInfo    *lchCfgInfo;
359 #endif
360 {
361    Buffer *mBuf = NULLP;
362
363    TRC2(cmPkPrgPMacSMacUeSCellLchAddReq)
364
365    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
366    {
367       RETVALUE(RFAILED);
368    }
369    
370    if(SAddPstMsgMult((Data *)lchCfgInfo, sizeof(RgPrgUeSCellLchAddInfo),\
371             mBuf) != ROK)
372    {
373       RGPRG_FREE_MSG(mBuf);
374       RETVALUE(RFAILED);
375    }
376
377    pst->event = (Event) EVTPRGUESCELLLCHADDREQ;
378    RETVALUE(SPstTsk(pst,mBuf));
379 }
380
381 /** 
382  * @brief LCH Addition Req from PMac to SMac.
383  * @details This primitive is used for light-weight loose coupling.
384  *
385  * @details
386  *
387  *     Function : cmUnpkPrgPMacSMacUeSCellLchAddReq
388  *
389  *  @param[in]   Pst*                     pst
390  *  @param[in]   RgPrgUeSCellLchAddInfo   *lchCfgInfo
391  *  @param[in]Buffer                      *mBuf
392  *  @return   S16
393  *      -# ROK
394  **/
395 #ifdef ANSI
396 PUBLIC S16 cmUnpkPrgPMacSMacUeSCellLchAddReq
397 (
398 RgPrgUeSCellLchAddInfo       func,
399 Pst                          *pst,
400 Buffer                       *mBuf
401 )
402 #else
403 PUBLIC S16 cmUnpkPrgPMacSMacUeSCellLchAddReq(func, pst, mBuf)
404 RgPrgUeSCellLchAddInfo       func;
405 Pst                          *pst;
406 Buffer                       *mBuf;
407 #endif
408 {
409    RgPrgLchRecfgInfo    lchCfgInfo;
410    
411    TRC2(cmUnpkPrgPMacSMacUeSCellLchAddReq)
412
413    if(SRemPreMsgMult((Data *)&lchCfgInfo, sizeof(RgPrgUeSCellLchAddInfo), mBuf) != ROK)
414    {
415       RGPRG_FREE_MSG(mBuf);
416       RETVALUE(RFAILED);
417    }
418
419    RGPRG_FREE_MSG(mBuf);
420    RETVALUE((*func)(pst, &lchCfgInfo));
421 }
422
423 /** 
424  * @brief Ue SCell Delete Req from PMac to SMac.
425  * @details This primitive is used for light-weight loose coupling.
426  *
427  * @details
428  *
429  *     Function : cmPkPrgPMacSMacUeSCellLchDelReq
430  *
431  *  @param[in]   Pst                       *pst
432  *  @param[in]   RgPrgUeSCellLchDelInfo    *delLcCb
433  *  @return   S16
434  *      -# ROK
435  **/
436 #ifdef ANSI
437 PUBLIC S16 cmPkPrgPMacSMacUeSCellLchDelReq
438 (
439 Pst                       *pst,
440 RgPrgUeSCellLchDelInfo    *delLcCb
441 )
442 #else
443 PUBLIC S16 cmPkPrgPMacSMacUeSCellLchDelReq(pst, delLcCb)
444 Pst                       *pst;
445 RgPrgUeSCellLchDelInfo    *delLcCb;
446 #endif
447 {
448    Buffer *mBuf = NULLP;
449
450    TRC2(cmPkPrgPMacSMacUeSCellLchDelReq)
451
452    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
453    {
454       RETVALUE(RFAILED);
455    }
456    
457    if(SAddPstMsgMult((Data *)delLcCb, sizeof(RgPrgUeSCellLchDelInfo),\
458             mBuf) != ROK)
459    {
460       RGPRG_FREE_MSG(mBuf);
461       RETVALUE(RFAILED);
462    }
463
464    pst->event = (Event) EVTPRGUESCELLLCHDELREQ;
465    RETVALUE(SPstTsk(pst,mBuf));
466 }
467
468
469 /** 
470  * @brief Ue Lch reCfg Req from PMac to SMac.
471  * @details This primitive is used for light-weight loose coupling.
472  *
473  * @details
474  *
475  *     Function : cmPkPrgPMacSMacUeSCellLchModReq
476  *
477  *  @param[in]   Pst                      *pst
478  *  @param[in]   RgPrgUeSCellLchModInfo   *lchCfgInfo
479  *  @return   S16
480  *      -# ROK
481  **/
482 #ifdef ANSI
483 PUBLIC S16 cmPkPrgPMacSMacUeSCellLchModReq
484 (
485 Pst                      *pst,
486 RgPrgUeSCellLchModInfo   *lchCfgInfo
487 )
488 #else
489 PUBLIC S16 cmPkPrgPMacSMacUeSCellLchModReq(pst, lchCfgInfo)
490 Pst                       *pst;
491 RgPrgUeSCellLchModInfo    *lchCfgInfo;
492 #endif
493 {
494    Buffer *mBuf = NULLP;
495
496    TRC2(cmPkPrgPMacSMacUeSCellLchModReq)
497
498    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
499    {
500       RETVALUE(RFAILED);
501    }
502    
503    if(SAddPstMsgMult((Data *)lchCfgInfo, sizeof(RgPrgUeSCellLchModInfo),\
504             mBuf) != ROK)
505    {
506       RGPRG_FREE_MSG(mBuf);
507       RETVALUE(RFAILED);
508    }
509
510    pst->event = (Event) EVTPRGUESCELLLCHMODREQ;
511    RETVALUE(SPstTsk(pst,mBuf));
512 }
513
514
515 /** 
516  * @brief LCH Cfg Req from PMac to SMac.
517  * @details This primitive is used for light-weight loose coupling.
518  *
519  * @details
520  *
521  *     Function : cmUnpkPrgPMacSMacUeSCellLchModReq
522  *
523  *  @param[in]   Pst*                pst
524  *  @param[in]   RgPrgLchRecfgInfo   *lchCfgInfo
525  *  @param[in]   Buffer              *mBuf
526  *  @return   S16
527  *      -# ROK
528  **/
529 #ifdef ANSI
530 PUBLIC S16 cmUnpkPrgPMacSMacUeSCellLchModReq
531 (
532 RgPrgUeScellModLchReq   func,
533 Pst                     *pst,
534 Buffer                  *mBuf
535 )
536 #else
537 PUBLIC S16 cmUnpkPrgPMacSMacAddLchCfgReq(func, pst, mBuf)
538 RgPrgUeScellModLchReq   func;
539 Pst                     *pst;
540 Buffer                  *mBuf;
541 #endif
542 {
543    RgPrgUeSCellLchModInfo   lchCfgInfo;
544    
545    TRC2(cmUnpkPrgPMacSMacAddLchCfgReq)
546
547    if(SRemPreMsgMult((Data *)&lchCfgInfo, sizeof(RgPrgUeSCellLchModInfo), mBuf) != ROK)
548    {
549       RGPRG_FREE_MSG(mBuf);
550       RETVALUE(RFAILED);
551    }
552
553    RGPRG_FREE_MSG(mBuf);
554    RETVALUE((*func)(pst, &lchCfgInfo));
555 }
556
557
558 /** 
559  * @brief LCH Del Req from PMac to SMac.
560  * @details This primitive is used for light-weight loose coupling.
561  *
562  * @details
563  *
564  *     Function : cmUnpkPrgPMacSMacUeSCellLchDelReq
565  *
566  *  @param[in]   Pst*                    pst
567  *  @param[in]   RgPrgUeScellDelLchReq   func;
568  *  @param[in]   Buffer                  *mBuf;
569  *  @return      S16
570  *      -# ROK
571  **/
572 #ifdef ANSI
573 PUBLIC S16 cmUnpkPrgPMacSMacUeSCellLchDelReq
574 (
575 RgPrgUeScellDelLchReq   func,
576 Pst                     *pst,
577 Buffer                  *mBuf
578 )
579 #else
580 PUBLIC S16 cmUnpkPrgPMacSMacUeSCellLchDelReq(func, pst, mBuf)
581 RgPrgUeScellDelLchReq   func;
582 Pst                     *pst;
583 Buffer                  *mBuf;
584 #endif
585 {
586    RgPrgUeSCellLchDelInfo   lchCfgInfo;
587    
588    TRC2(cmUnpkPrgPMacSMacUeSCellLchDelReq)
589
590    if(SRemPreMsgMult((Data *)&lchCfgInfo, sizeof(RgPrgUeSCellLchDelInfo), mBuf) != ROK)
591    {
592       RGPRG_FREE_MSG(mBuf);
593       RETVALUE(RFAILED);
594    }
595
596    RGPRG_FREE_MSG(mBuf);
597    RETVALUE((*func)(pst, &lchCfgInfo));
598 }
599
600 #endif /*LCPRG*/ 
601 #endif /*LTE_ADV*/
602
603 /**********************************************************************
604  
605          End of file
606 **********************************************************************/