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