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 int 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 return SPstTsk(pst,mBuf);
81 /**************************************************************************
82 * @brief Function to pack Loose Coupled
83 * MAC cell config parameters required by MAC
87 * Function : unpackDuMacCellCfg
90 * packs the macCellCfg parameters
92 * @param[in] DuMacCellCfgReq func; function pointer
93 * @param[in] Pst *pst, Post structure of the primitive.
94 * @param[in] Buffer *mBuf
95 * @return ROK - success
98 ***************************************************************************/
99 int unpackDuMacCellCfg(
100 DuMacCellCfgReq func,
105 MacCellCfg *macCellCfg;
107 if(pst->selector == DU_SELECTOR_LWLC)
109 /* unpack the address of the structure */
110 CMCHKUNPK(cmUnpkPtr, (PTR *)&macCellCfg, mBuf);
111 ret = (*func)(pst, macCellCfg);
115 /* only LWLC is implemented now */
122 /**************************************************************************
123 * @brief Function to pack Loose Coupled
124 * MAC cell config confirm message
128 * Function : packMacCellCfgCfm
131 * packs the transaction ID
133 * @param[in] Pst *pst, Post structure of the primitive.
134 * @param[in] MacCellCfgCfm *macCellCfgCfm, mac cell config confirm.
135 * @return ROK - success
138 ***************************************************************************/
139 int packMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
141 if(pst->selector == DU_SELECTOR_LC)
143 Buffer *mBuf = NULLP;
144 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
149 /* pack the transaction ID in CNF structure */
150 CMCHKPK(SPkU8, macCellCfgCfm->rsp, mBuf);
151 CMCHKPK(SPkU16, macCellCfgCfm->transId, mBuf);
153 return SPstTsk(pst,mBuf);
155 else if(pst->selector == DU_SELECTOR_LWLC)
157 /* only LC is supported */
163 /**************************************************************************
164 * @brief Function to pack MAC cell config confirm message
168 * Function : unpackMacCellCfgCfm
171 * packs the transaction ID
173 * @param[in] DuMacCellCfgCfm func; function pointer
174 * @param[in] Pst *pst, Post structure of the primitive.
175 * @param[in] Buffer *mBuf
176 * @return ROK - success
179 ***************************************************************************/
180 int unpackMacCellCfgCfm(
181 DuMacCellCfgCfm func,
185 MacCellCfgCfm macCellCfgCfm;
187 if(pst->selector == DU_SELECTOR_LC)
189 /* unpack the transaction ID in CNF structure */
190 CMCHKUNPK(SUnpkU16, &(macCellCfgCfm.transId), mBuf);
191 CMCHKUNPK(SUnpkU8, &(macCellCfgCfm.rsp), mBuf);
193 return (*func)(pst, &macCellCfgCfm);
197 /* only loose coupling is suported */
202 /*******************************************************************
204 * @brief Packs and Send Cell Start Request to MAC
208 * Function : packMacCellStartReq
211 * Packs and Sends Cell Start Request to MAC
213 * @params[in] Post structure pointer
214 * MacCellStartInfo pointer
215 * @return ROK - success
218 * ****************************************************************/
219 uint16_t packMacCellStartReq(Pst *pst, MacCellStartInfo *cellStartInfo)
221 if(pst->selector == DU_SELECTOR_LC)
223 /* Loose coupling not supported */
226 else if(pst->selector == DU_SELECTOR_LWLC)
228 Buffer *mBuf = NULLP;
230 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
232 DU_LOG("\nDU APP : Memory allocation failed for cell start req pack");
236 /* pack the address of the structure */
237 CMCHKPK(cmPkPtr,(PTR)cellStartInfo, mBuf);
239 return SPstTsk(pst,mBuf);
244 /*******************************************************************
246 * @brief Unpacks MAC Cell Start Request from DU APP
250 * Function : unpackMaCellStartReq
253 * Unpacks MAC Cell Start Request from DU APP
255 * @params[in] Function pointer of cell start request handler
256 * Post structure pointer
257 * Cell Start Request Info Pointer
258 * @return ROK - success
261 * ****************************************************************/
262 uint16_t unpackMacCellStartReq(DuMacCellStartReq func, Pst *pst, Buffer *mBuf)
264 MacCellStartInfo *cellStartInfo;
266 if(pst->selector == DU_SELECTOR_LWLC)
268 /* unpack the address of the structure */
269 CMCHKUNPK(cmUnpkPtr, (PTR *)&cellStartInfo, mBuf);
271 return (*func)(pst, cellStartInfo);
275 /* Nothing to do for loose coupling */
281 /*******************************************************************
283 * @brief Packs and Send cell stop request to MAC
287 * Function : packMacCellStopReq
290 * Packs and Send cell stop request to MAC
292 * @params[in] Post structure pointer
293 * Cell stop info structure
294 * @return ROK - success
297 * ****************************************************************/
298 uint16_t packMacCellStopReq(Pst *pst, MacCellStopInfo *cellStopInfo)
300 if(pst->selector == DU_SELECTOR_LC)
302 /* Loose coupling not supported */
305 else if(pst->selector == DU_SELECTOR_LWLC)
307 Buffer *mBuf = NULLP;
309 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
311 DU_LOG("\nDU APP : Memory allocation failed for cell stop req pack");
315 /* pack the address of the structure */
316 CMCHKPK(cmPkPtr,(PTR)cellStopInfo, mBuf);
318 return SPstTsk(pst,mBuf);
323 /*******************************************************************
325 * @brief Unpacks cell stop request from DU APP
329 * Function : unpackMaCellStopReq
332 * Unpacks cell stop request from DU APP
334 * @params[in] Handler function pointer
335 * Post structure pointer
337 * @return ROK - success
340 * ****************************************************************/
341 uint16_t unpackMacCellStopReq(DuMacCellStopReq func, Pst *pst, Buffer *mBuf)
343 MacCellStopInfo *cellStopInfo;
345 if(pst->selector == DU_SELECTOR_LWLC)
347 /* unpack the address of the structure */
348 CMCHKUNPK(cmUnpkPtr, (PTR *)&cellStopInfo, mBuf);
350 return (*func)(pst, cellStopInfo);
354 /* Nothing to do for loose coupling */
360 /*******************************************************************
362 * @brief Packs and Sends slot ind from MAC to DUAPP
366 * Function : packMacSlotInd
369 * Packs and Sends slot ind from MAC to DUAPP
371 * @params[in] Post structure pointer
373 * @return ROK - success
376 * ****************************************************************/
377 uint16_t packMacSlotInd(Pst *pst, SlotInfo *slotInfo )
379 if(pst->selector == DU_SELECTOR_LC || pst->selector == DU_SELECTOR_TC)
381 /* Loose coupling not supported */
382 DU_LOG("\nDU APP : Only LWLC supported");
385 else if(pst->selector == DU_SELECTOR_LWLC)
387 Buffer *mBuf = NULLP;
389 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
391 DU_LOG("\nDU APP : Memory allocation failed for cell start req pack");
395 /* pack the address of the structure */
396 CMCHKPK(cmPkPtr,(PTR)slotInfo, mBuf);
398 return SPstTsk(pst,mBuf);
403 /*******************************************************************
405 * @brief Unpacks slot indication from MAC
409 * Function : unpackMacSlotInd
412 * Unpacks slot indication from MAC
414 * @params[in] Pointer to Handler
415 * Post structure pointer
417 * @return ROK - success
420 * ****************************************************************/
421 uint16_t unpackMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf)
425 if(pst->selector == DU_SELECTOR_LWLC)
427 /* unpack the address of the structure */
428 CMCHKUNPK(cmUnpkPtr, (PTR *)&slotInfo, mBuf);
430 return (*func)(pst, slotInfo);
434 /* Nothing to do for loose coupling */
441 /**********************************************************************
443 **********************************************************************/