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"
40 /**************************************************************************
41 * @brief Function to pack Loose Coupled
42 * MAC cell config parameters required by MAC
46 * Function : packMacCellCfg
49 * packs the macCellCfg parameters
51 * @param[in] Pst *pst, Post structure of the primitive.
52 * @param[in] MacCellCfg *macCellCfg, mac cell config parameters.
53 * @return ROK - success
56 ***************************************************************************/
57 int packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg)
59 if(pst->selector == DU_SELECTOR_LC)
61 /* we are now implemented only light wieght lossely coupled interface */
64 else if(pst->selector == DU_SELECTOR_LWLC)
68 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
73 /* pack the address of the structure */
74 CMCHKPK(cmPkPtr,(PTR)macCellCfg, mBuf);
76 DU_LOG("\nDU-APP : MAC CELL config sent");
77 return SPstTsk(pst,mBuf);
82 /**************************************************************************
83 * @brief Function to pack Loose Coupled
84 * MAC cell config parameters required by MAC
88 * Function : unpackDuMacCellCfg
91 * packs the macCellCfg parameters
93 * @param[in] DuMacCellCfgReq func; function pointer
94 * @param[in] Pst *pst, Post structure of the primitive.
95 * @param[in] Buffer *mBuf
96 * @return ROK - success
99 ***************************************************************************/
100 int unpackDuMacCellCfg(
101 DuMacCellCfgReq func,
106 MacCellCfg *macCellCfg;
108 if(pst->selector == DU_SELECTOR_LWLC)
110 /* unpack the address of the structure */
111 CMCHKUNPK(cmUnpkPtr, (PTR *)&macCellCfg, mBuf);
112 ret = (*func)(pst, macCellCfg);
116 /* only LWLC is implemented now */
123 /**************************************************************************
124 * @brief Function to pack Loose Coupled
125 * MAC cell config confirm message
129 * Function : packMacCellCfgCfm
132 * packs the transaction ID
134 * @param[in] Pst *pst, Post structure of the primitive.
135 * @param[in] MacCellCfgCfm *macCellCfgCfm, mac cell config confirm.
136 * @return ROK - success
139 ***************************************************************************/
140 int packMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
142 if(pst->selector == DU_SELECTOR_LC)
144 Buffer *mBuf = NULLP;
145 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
150 /* pack the transaction ID in CNF structure */
151 CMCHKPK(SPkU8, macCellCfgCfm->rsp, mBuf);
152 CMCHKPK(SPkU16, macCellCfgCfm->transId, mBuf);
154 return SPstTsk(pst,mBuf);
156 else if(pst->selector == DU_SELECTOR_LWLC)
158 /* only LC is supported */
164 /**************************************************************************
165 * @brief Function to pack MAC cell config confirm message
169 * Function : unpackMacCellCfgCfm
172 * packs the transaction ID
174 * @param[in] DuMacCellCfgCfm func; function pointer
175 * @param[in] Pst *pst, Post structure of the primitive.
176 * @param[in] Buffer *mBuf
177 * @return ROK - success
180 ***************************************************************************/
181 int unpackMacCellCfgCfm(
182 DuMacCellCfgCfm func,
186 MacCellCfgCfm macCellCfgCfm;
188 if(pst->selector == DU_SELECTOR_LC)
190 /* unpack the transaction ID in CNF structure */
191 CMCHKUNPK(SUnpkU16, &(macCellCfgCfm.transId), mBuf);
192 CMCHKUNPK(SUnpkU8, &(macCellCfgCfm.rsp), mBuf);
194 return (*func)(pst, &macCellCfgCfm);
198 /* only loose coupling is suported */
203 /*******************************************************************
205 * @brief Packs and Send Cell Start Request to MAC
209 * Function : packMacCellStartReq
212 * Packs and Sends Cell Start Request to MAC
214 * @params[in] Post structure pointer
215 * MacCellStartInfo pointer
216 * @return ROK - success
219 * ****************************************************************/
220 uint16_t packMacCellStartReq(Pst *pst, MacCellStartInfo *cellStartInfo)
222 if(pst->selector == DU_SELECTOR_LC)
224 /* Loose coupling not supported */
227 else if(pst->selector == DU_SELECTOR_LWLC)
229 Buffer *mBuf = NULLP;
231 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
233 DU_LOG("\nDU APP : Memory allocation failed for cell start req pack");
237 /* pack the address of the structure */
238 CMCHKPK(cmPkPtr,(PTR)cellStartInfo, mBuf);
240 return SPstTsk(pst,mBuf);
245 /*******************************************************************
247 * @brief Unpacks MAC Cell Start Request from DU APP
251 * Function : unpackMaCellStartReq
254 * Unpacks MAC Cell Start Request from DU APP
256 * @params[in] Function pointer of cell start request handler
257 * Post structure pointer
258 * Cell Start Request Info Pointer
259 * @return ROK - success
262 * ****************************************************************/
263 uint16_t unpackMacCellStartReq(DuMacCellStartReq func, Pst *pst, Buffer *mBuf)
265 MacCellStartInfo *cellStartInfo;
267 if(pst->selector == DU_SELECTOR_LWLC)
269 /* unpack the address of the structure */
270 CMCHKUNPK(cmUnpkPtr, (PTR *)&cellStartInfo, mBuf);
272 return (*func)(pst, cellStartInfo);
276 /* Nothing to do for loose coupling */
282 /*******************************************************************
284 * @brief Packs and Send cell stop request to MAC
288 * Function : packMacCellStopReq
291 * Packs and Send cell stop request to MAC
293 * @params[in] Post structure pointer
294 * Cell stop info structure
295 * @return ROK - success
298 * ****************************************************************/
299 uint16_t packMacCellStopReq(Pst *pst, MacCellStopInfo *cellStopInfo)
301 if(pst->selector == DU_SELECTOR_LC)
303 /* Loose coupling not supported */
306 else if(pst->selector == DU_SELECTOR_LWLC)
308 Buffer *mBuf = NULLP;
310 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
312 DU_LOG("\nDU APP : Memory allocation failed for cell stop req pack");
316 /* pack the address of the structure */
317 CMCHKPK(cmPkPtr,(PTR)cellStopInfo, mBuf);
319 return SPstTsk(pst,mBuf);
324 /*******************************************************************
326 * @brief Unpacks cell stop request from DU APP
330 * Function : unpackMaCellStopReq
333 * Unpacks cell stop request from DU APP
335 * @params[in] Handler function pointer
336 * Post structure pointer
338 * @return ROK - success
341 * ****************************************************************/
342 uint16_t unpackMacCellStopReq(DuMacCellStopReq func, Pst *pst, Buffer *mBuf)
344 MacCellStopInfo *cellStopInfo;
346 if(pst->selector == DU_SELECTOR_LWLC)
348 /* unpack the address of the structure */
349 CMCHKUNPK(cmUnpkPtr, (PTR *)&cellStopInfo, mBuf);
351 return (*func)(pst, cellStopInfo);
355 /* Nothing to do for loose coupling */
361 /*******************************************************************
363 * @brief Packs and Sends slot ind from MAC to DUAPP
367 * Function : packMacSlotInd
370 * Packs and Sends slot ind from MAC to DUAPP
372 * @params[in] Post structure pointer
374 * @return ROK - success
377 * ****************************************************************/
378 uint16_t packMacSlotInd(Pst *pst, SlotInfo *slotInfo )
380 Buffer *mBuf = NULLP;
382 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
384 DU_LOG("\nDU APP : Memory allocation failed for cell start req pack");
388 if(pst->selector == DU_SELECTOR_LC)
390 CMCHKPK(SPkU16, slotInfo->cellId, mBuf);
391 CMCHKPK(SPkU16, slotInfo->sfn, mBuf);
392 CMCHKPK(SPkU16, slotInfo->slot, mBuf);
394 CM_FREE_SHRABL_BUF(pst->region, pst->pool, slotInfo, sizeof(SlotInfo));
397 else if(pst->selector == DU_SELECTOR_LWLC)
399 /* pack the address of the structure */
400 CMCHKPK(cmPkPtr,(PTR)slotInfo, mBuf);
407 return SPstTsk(pst,mBuf);
410 /*******************************************************************
412 * @brief Unpacks slot indication from MAC
416 * Function : unpackMacSlotInd
419 * Unpacks slot indication from MAC
421 * @params[in] Pointer to Handler
422 * Post structure pointer
424 * @return ROK - success
427 * ****************************************************************/
428 uint16_t unpackMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf)
430 if(pst->selector == DU_SELECTOR_LWLC)
434 /* unpack the address of the structure */
435 CMCHKUNPK(cmUnpkPtr, (PTR *)&slotInfo, mBuf);
437 return (*func)(pst, slotInfo);
439 else if(pst->selector == DU_SELECTOR_LC)
443 CMCHKUNPK(SUnpkU16, &(slotInfo.slot), mBuf);
444 CMCHKUNPK(SUnpkU16, &(slotInfo.sfn), mBuf);
445 CMCHKUNPK(SUnpkU16, &(slotInfo.cellId), mBuf);
448 return (*func)(pst, &slotInfo);
453 /* Nothing to do for loose coupling */
460 /*******************************************************************
462 * @brief Packs and Sends stop ind from MAC to DUAPP
466 * Function : packMacStopInd
469 * Packs and Sends stop ind from MAC to DUAPP
471 * @params[in] Post structure pointer
472 * @return ROK - success
475 * ****************************************************************/
476 uint16_t packMacStopInd(Pst *pst, MacCellStopInfo *cellStopId)
478 Buffer *mBuf = NULLP;
480 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
482 DU_LOG("\nDU APP : Memory allocation failed for stop Ind pack");
486 if(pst->selector == DU_SELECTOR_LC)
488 /*pack the payload here*/
489 DU_LOG("\nDU APP : Packed CellId");
490 CMCHKPK(SPkU16, cellStopId->cellId, mBuf);
491 CM_FREE_SHRABL_BUF(pst->region, pst->pool, cellStopId, sizeof(MacCellStopInfo));
494 else if(pst->selector == DU_SELECTOR_LWLC)
496 /* pack the address of the structure */
497 CMCHKPK(cmPkPtr,(PTR)cellStopId, mBuf);
504 return SPstTsk(pst,mBuf);
507 /*******************************************************************
509 * @brief Unpacks stop indication from MAC
513 * Function : unpackMacStopInd
516 * Unpacks stop indication from MAC
518 * @params[in] Pointer to Handler
519 * Post structure pointer
521 * @return ROK - success
524 * ****************************************************************/
525 uint16_t unpackMacStopInd(DuMacStopInd func, Pst *pst, Buffer *mBuf)
527 if(pst->selector == DU_SELECTOR_LWLC)
529 MacCellStopInfo *cellStopId;
530 /* unpack the address of the structure */
531 CMCHKUNPK(cmUnpkPtr, (PTR *)&cellStopId, mBuf);
533 return (*func)(pst, cellStopId);
535 else if(pst->selector == DU_SELECTOR_LC)
537 MacCellStopInfo cellStopId;
538 CMCHKUNPK(SUnpkU16, &(cellStopId.cellId), mBuf);
541 return (*func)(pst, &cellStopId);
546 /* Nothing to do for loose coupling */
552 /**********************************************************************
554 **********************************************************************/