1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
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 */
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 */
37 #include "du_app_mac_inf.h"
39 /**************************************************************************
40 * @brief Function to pack Loose Coupled
41 * MAC cell config parameters required by MAC
45 * Function : packMacCellCfg
48 * packs the macCellCfg parameters
50 * @param[in] Pst *pst, Post structure of the primitive.
51 * @param[in] MacCellCfg *macCellCfg, mac cell config parameters.
52 * @return ROK - success
55 ***************************************************************************/
56 uint16_t packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg)
58 if(pst->selector == DU_SELECTOR_LC)
60 /* we are now implemented only light wieght lossely coupled interface */
63 else if(pst->selector == DU_SELECTOR_LWLC)
67 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
72 /* pack the address of the structure */
73 CMCHKPK(cmPkPtr,(PTR)macCellCfg, mBuf);
75 DU_LOG("\nDU-APP : MAC CELL config sent");
76 RETVALUE(SPstTsk(pst,mBuf));
80 /**************************************************************************
81 * @brief Function to pack Loose Coupled
82 * MAC cell config parameters required by MAC
86 * Function : unpackDuMacCellCfg
89 * packs the macCellCfg parameters
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
97 ***************************************************************************/
98 void unpackDuMacCellCfg(
104 MacCellCfg *macCellCfg;
106 if(pst->selector == DU_SELECTOR_LWLC)
108 /* unpack the address of the structure */
109 CMCHKUNPK(cmUnpkPtr, (PTR *)&macCellCfg, mBuf);
110 ret = (*func)(pst, macCellCfg);
114 /* only LWLC is implemented now */
121 /**************************************************************************
122 * @brief Function to pack Loose Coupled
123 * MAC cell config confirm message
127 * Function : packMacCellCfgCfm
130 * packs the transaction ID
132 * @param[in] Pst *pst, Post structure of the primitive.
133 * @param[in] MacCellCfgCfm *macCellCfgCfm, mac cell config confirm.
134 * @return ROK - success
137 ***************************************************************************/
138 uint16_t packMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
140 if(pst->selector == DU_SELECTOR_LC)
142 Buffer *mBuf = NULLP;
143 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
148 /* pack the transaction ID in CNF structure */
149 CMCHKPK(SPkU8, macCellCfgCfm->rsp, mBuf);
150 CMCHKPK(SPkU16, macCellCfgCfm->transId, mBuf);
152 RETVALUE(SPstTsk(pst,mBuf));
154 else if(pst->selector == DU_SELECTOR_LWLC)
156 /* only LC is supported */
162 /**************************************************************************
163 * @brief Function to pack MAC cell config confirm message
167 * Function : unpackMacCellCfgCfm
170 * packs the transaction ID
172 * @param[in] DuMacCellCfgCfm func; function pointer
173 * @param[in] Pst *pst, Post structure of the primitive.
174 * @param[in] Buffer *mBuf
175 * @return ROK - success
178 ***************************************************************************/
179 uint16_t unpackMacCellCfgCfm(
180 DuMacCellCfgCfm func,
184 MacCellCfgCfm macCellCfgCfm;
186 if(pst->selector == DU_SELECTOR_LC)
188 /* unpack the transaction ID in CNF structure */
189 CMCHKUNPK(SUnpkU16, &(macCellCfgCfm.transId), mBuf);
190 CMCHKUNPK(SUnpkU8, &(macCellCfgCfm.rsp), mBuf);
192 RETVALUE((*func)(&macCellCfgCfm));
196 /* only loose coupling is suported */
200 /*******************************************************************
202 * @brief Packs and Send Cell Start Request to MAC
206 * Function : packMacCellStartReq
209 * Packs and Sends Cell Start Request to MAC
211 * @params[in] Post structure pointer
212 * MacCellStartInfo pointer
213 * @return ROK - success
216 * ****************************************************************/
217 uint16_t packMacCellStartReq(Pst *pst, MacCellStartInfo *cellStartInfo)
219 if(pst->selector == DU_SELECTOR_LC)
221 /* Loose coupling not supported */
224 else if(pst->selector == DU_SELECTOR_LWLC)
226 Buffer *mBuf = NULLP;
228 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
230 DU_LOG("\nDU APP : Memory allocation failed for cell start req pack");
234 /* pack the address of the structure */
235 CMCHKPK(cmPkPtr,(PTR)cellStartInfo, mBuf);
237 return SPstTsk(pst,mBuf);
242 /*******************************************************************
244 * @brief Unpacks MAC Cell Start Request from DU APP
248 * Function : unpackMaCellStartReq
251 * Unpacks MAC Cell Start Request from DU APP
253 * @params[in] Function pointer of cell start request handler
254 * Post structure pointer
255 * Cell Start Request Info Pointer
256 * @return ROK - success
259 * ****************************************************************/
260 uint16_t unpackMacCellStartReq(DuMacCellStartReq func, Pst *pst, Buffer *mBuf)
262 MacCellStartInfo *cellStartInfo;
264 if(pst->selector == DU_SELECTOR_LWLC)
266 /* unpack the address of the structure */
267 CMCHKUNPK(cmUnpkPtr, (PTR *)&cellStartInfo, mBuf);
269 return (*func)(pst, cellStartInfo);
273 /* Nothing to do for loose coupling */
279 /*******************************************************************
281 * @brief Packs and Send cell stop request to MAC
285 * Function : packMacCellStopReq
288 * Packs and Send cell stop request to MAC
290 * @params[in] Post structure pointer
291 * Cell stop info structure
292 * @return ROK - success
295 * ****************************************************************/
296 uint16_t packMacCellStopReq(Pst *pst, MacCellStopInfo *cellStopInfo)
298 if(pst->selector == DU_SELECTOR_LC)
300 /* Loose coupling not supported */
303 else if(pst->selector == DU_SELECTOR_LWLC)
305 Buffer *mBuf = NULLP;
307 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
309 DU_LOG("\nDU APP : Memory allocation failed for cell stop req pack");
313 /* pack the address of the structure */
314 CMCHKPK(cmPkPtr,(PTR)cellStopInfo, mBuf);
316 return SPstTsk(pst,mBuf);
321 /*******************************************************************
323 * @brief Unpacks cell stop request from DU APP
327 * Function : unpackMaCellStopReq
330 * Unpacks cell stop request from DU APP
332 * @params[in] Handler function pointer
333 * Post structure pointer
335 * @return ROK - success
338 * ****************************************************************/
339 uint16_t unpackMacCellStopReq(DuMacCellStopReq func, Pst *pst, Buffer *mBuf)
341 MacCellStopInfo *cellStopInfo;
343 if(pst->selector == DU_SELECTOR_LWLC)
345 /* unpack the address of the structure */
346 CMCHKUNPK(cmUnpkPtr, (PTR *)&cellStopInfo, mBuf);
348 return (*func)(pst, cellStopInfo);
352 /* Nothing to do for loose coupling */
358 /*******************************************************************
360 * @brief Packs and Sends slot ind from MAC to DUAPP
364 * Function : packMacSlotInd
367 * Packs and Sends slot ind from MAC to DUAPP
369 * @params[in] Post structure pointer
371 * @return ROK - success
374 * ****************************************************************/
375 uint16_t packMacSlotInd(Pst *pst, SlotInfo *slotInfo )
377 if(pst->selector == DU_SELECTOR_LC || pst->selector == DU_SELECTOR_TC)
379 /* Loose coupling not supported */
380 DU_LOG("\nDU APP : Only LWLC supported");
383 else if(pst->selector == DU_SELECTOR_LWLC)
385 Buffer *mBuf = NULLP;
387 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
389 DU_LOG("\nDU APP : Memory allocation failed for cell start req pack");
393 /* pack the address of the structure */
394 CMCHKPK(cmPkPtr,(PTR)slotInfo, mBuf);
396 return SPstTsk(pst,mBuf);
401 /*******************************************************************
403 * @brief Unpacks slot indication from MAC
407 * Function : unpackMacSlotInd
410 * Unpacks slot indication from MAC
412 * @params[in] Pointer to Handler
413 * Post structure pointer
415 * @return ROK - success
418 * ****************************************************************/
419 uint16_t unpackMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf)
423 if(pst->selector == DU_SELECTOR_LWLC)
425 /* unpack the address of the structure */
426 CMCHKUNPK(cmUnpkPtr, (PTR *)&slotInfo, mBuf);
428 return (*func)(pst, slotInfo);
432 /* Nothing to do for loose coupling */
439 /**********************************************************************
441 **********************************************************************/