Configured cell list changes
[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 S16 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       RETVALUE(SPstTsk(pst,mBuf));
76    } 
77 }
78
79 /**************************************************************************
80  * @brief Function to pack Loose Coupled 
81  *        MAC cell config parameters required by MAC
82  *
83  * @details
84  *
85  *      Function : unpackDuMacCellCfg
86  *
87  *      Functionality:
88  *           packs the macCellCfg parameters
89  *
90  * @param[in] DuMacCellCfgReq func; function pointer
91  * @param[in] Pst     *pst, Post structure of the primitive.
92  * @param[in] Buffer *mBuf
93  * @return ROK     - success
94  *         RFAILED - failure
95  *
96  ***************************************************************************/
97 void unpackDuMacCellCfg(
98    DuMacCellCfgReq func,
99    Pst *pst,
100    Buffer *mBuf)
101 {
102    U16 ret = ROK;
103    MacCellCfg *macCellCfg;
104
105    if(pst->selector == DU_SELECTOR_LWLC)
106    {
107       /* unpack the address of the structure */
108       CMCHKUNPK(cmUnpkPtr, (PTR *)&macCellCfg, mBuf);
109       ret = (*func)(pst, macCellCfg);
110    }
111    else
112    {
113       /* only LWLC is implemented now */
114       ret = ROK;
115    }
116  
117    return ret;
118 }
119
120 /**************************************************************************
121  * @brief Function to pack Loose Coupled 
122  *        MAC cell config confirm message
123  *
124  * @details
125  *
126  *      Function : cmPackMacCellCfgCfm
127  *
128  *      Functionality:
129  *           packs the transaction ID  
130  *
131  * @param[in] Pst     *pst, Post structure of the primitive.
132  * @param[in] MacCellCfgCfm  *macCellCfgCfm, mac cell config confirm.
133  * @return ROK     - success
134  *         RFAILED - failure
135  *
136  ***************************************************************************/
137 U16 cmPackMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
138 {
139    if(pst->selector == DU_SELECTOR_LC)
140    {
141       Buffer *mBuf = NULLP;
142       if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
143       {
144          RETVALUE(RFAILED);
145       }
146
147       /* pack the transaction ID in CNF structure */
148       CMCHKPK(SPkU16, macCellCfgCfm->transId, mBuf);
149
150       RETVALUE(SPstTsk(pst,mBuf));
151    }
152    else if(pst->selector == DU_SELECTOR_LWLC)
153    {
154       /* only LC is supported */
155       return RFAILED;
156    }
157 }
158
159 /**************************************************************************
160  * @brief Function to pack MAC cell config confirm message
161  *
162  * @details
163  *
164  *      Function : unpackMacCellCfgCfm
165  *
166  *      Functionality:
167  *           packs the transaction ID  
168  *
169  * @param[in] DuMacCellCfgCfm func; function pointer
170  * @param[in] Pst     *pst, Post structure of the primitive.
171  * @param[in] Buffer *mBuf
172  * @return ROK     - success
173  *         RFAILED - failure
174  *
175  ***************************************************************************/
176 S16 unpackMacCellCfgCfm(
177    DuMacCellCfgCfm func, 
178    Pst *pst,
179    Buffer *mBuf)
180 {
181    MacCellCfgCfm macCellCfgCfm;
182
183    if(pst->selector == DU_SELECTOR_LC)
184    {
185       /* unpack the transaction ID in CNF structure */
186       CMCHKUNPK(SUnpkU16, &(macCellCfgCfm.transId), mBuf);
187
188       RETVALUE((*func)(&macCellCfgCfm));
189    }
190    else
191    {
192       /* only loose coupling is suported */
193    }
194 }
195
196 /**********************************************************************
197          End of file
198 **********************************************************************/