Trigger_macCellCfg
[o-du/l2.git] / src / cm / du_app_mac_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 #include "envopt.h"        /* Environment options */
20 #include "envdep.h"        /* Environment dependent */
21 #include "envind.h"        /* Environment independent */
22 #include "gen.h"           /* General */
23 #include "ssi.h"           /* System services */
24 #include "ss_queue.h"
25 #include "ss_task.h"
26 #include "ss_msg.h"
27
28 #include "gen.x"           /* general */
29 #include "ssi.x"           /* system services */
30 #include "cm_tkns.x"       /* Common Token Definitions */
31 #include "cm_llist.x"      /* Common Link List Definitions */
32 #include "cm_lib.x"        /* Common Library Definitions */
33 #include "cm_hash.x"       /* Common Hash List Definitions */
34 #include "cm_lte.x"        /* Common LTE Defines */
35
36 #include "du_cfg.h"
37 #include "du_app_mac_inf.h"
38
39 /**************************************************************************
40  * @brief Function to pack Loose Coupled 
41  *        MAC cell config parameters required by MAC
42  *
43  * @details
44  *
45  *      Function : packMacCellCfg
46  *
47  *      Functionality:
48  *           packs the macCellCfg parameters
49  *
50  * @param[in] Pst     *pst, Post structure of the primitive.
51  * @param[in] MacCellCfg  *macCellCfg, mac cell config parameters.
52  * @return ROK     - success
53  *         RFAILED - failure
54  *
55  ***************************************************************************/
56 U16 packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg)
57 {
58    if(pst->selector == DU_SELECTOR_LC)
59    {
60       /* we are now implemented only light wieght lossely coupled interface */
61       return RFAILED;
62    }
63    else if(pst->selector == DU_SELECTOR_LWLC)
64    {
65       Buffer *mBuf = NULLP;
66
67       if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
68       {
69          RETVALUE(RFAILED);
70       }
71
72       /* pack the address of the structure */
73       CMCHKPK(cmPkPtr,(PTR)macCellCfg, mBuf);
74
75       DU_LOG("\nDU-APP : MAC CELL config sent");
76       RETVALUE(SPstTsk(pst,mBuf));
77    } 
78 }
79
80 /**************************************************************************
81  * @brief Function to pack Loose Coupled 
82  *        MAC cell config parameters required by MAC
83  *
84  * @details
85  *
86  *      Function : unpackDuMacCellCfg
87  *
88  *      Functionality:
89  *           packs the macCellCfg parameters
90  *
91  * @param[in] DuMacCellCfgReq func; function pointer
92  * @param[in] Pst     *pst, Post structure of the primitive.
93  * @param[in] Buffer *mBuf
94  * @return ROK     - success
95  *         RFAILED - failure
96  *
97  ***************************************************************************/
98 void unpackDuMacCellCfg(
99    DuMacCellCfgReq func,
100    Pst *pst,
101    Buffer *mBuf)
102 {
103    U16 ret = ROK;
104    MacCellCfg *macCellCfg;
105
106    if(pst->selector == DU_SELECTOR_LWLC)
107    {
108       /* unpack the address of the structure */
109       CMCHKUNPK(cmUnpkPtr, (PTR *)&macCellCfg, mBuf);
110       ret = (*func)(pst, macCellCfg);
111    }
112    else
113    {
114       /* only LWLC is implemented now */
115       ret = ROK;
116    }
117  
118    return ret;
119 }
120
121 /**************************************************************************
122  * @brief Function to pack Loose Coupled 
123  *        MAC cell config confirm message
124  *
125  * @details
126  *
127  *      Function : packMacCellCfgCfm
128  *
129  *      Functionality:
130  *           packs the transaction ID  
131  *
132  * @param[in] Pst     *pst, Post structure of the primitive.
133  * @param[in] MacCellCfgCfm  *macCellCfgCfm, mac cell config confirm.
134  * @return ROK     - success
135  *         RFAILED - failure
136  *
137  ***************************************************************************/
138 U16 packMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
139 {
140    if(pst->selector == DU_SELECTOR_LC)
141    {
142       Buffer *mBuf = NULLP;
143       if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
144       {
145          RETVALUE(RFAILED);
146       }
147
148       /* pack the transaction ID in CNF structure */
149       CMCHKPK(SPkU16, macCellCfgCfm->transId, mBuf);
150
151       RETVALUE(SPstTsk(pst,mBuf));
152    }
153    else if(pst->selector == DU_SELECTOR_LWLC)
154    {
155       /* only LC is supported */
156       return RFAILED;
157    }
158    return ROK;
159 }
160
161 /**************************************************************************
162  * @brief Function to pack MAC cell config confirm message
163  *
164  * @details
165  *
166  *      Function : unpackMacCellCfgCfm
167  *
168  *      Functionality:
169  *           packs the transaction ID  
170  *
171  * @param[in] DuMacCellCfgCfm func; function pointer
172  * @param[in] Pst     *pst, Post structure of the primitive.
173  * @param[in] Buffer *mBuf
174  * @return ROK     - success
175  *         RFAILED - failure
176  *
177  ***************************************************************************/
178 U16 unpackMacCellCfgCfm(
179    DuMacCellCfgCfm func, 
180    Pst *pst,
181    Buffer *mBuf)
182 {
183    MacCellCfgCfm macCellCfgCfm;
184
185    if(pst->selector == DU_SELECTOR_LC)
186    {
187       /* unpack the transaction ID in CNF structure */
188       CMCHKUNPK(SUnpkU16, &(macCellCfgCfm.transId), mBuf);
189
190       RETVALUE((*func)(&macCellCfgCfm));
191    }
192    else
193    {
194       /* only loose coupling is suported */
195    }
196    return ROK;
197 }
198
199 /**********************************************************************
200          End of file
201 **********************************************************************/