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