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