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