[Epic-ID: ODUHIGH-405][Task-ID: ODUHIGH-448]RACH resource release at target DU and...
[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 "common_def.h"
20 #include "du_app_mac_inf.h"
21
22 /**************************************************************************
23  * @brief Function to pack Loose Coupled 
24  *        MAC cell config parameters required by MAC
25  *
26  * @details
27  *
28  *      Function : packMacCellCfg
29  *
30  *      Functionality:
31  *           packs the macCellCfg parameters
32  *
33  * @param[in] Pst     *pst, Post structure of the primitive.
34  * @param[in] MacCellCfg  *macCellCfg, mac cell config parameters.
35  * @return ROK     - success
36  *         RFAILED - failure
37  *
38  ***************************************************************************/
39 uint8_t packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg)
40 {
41    if(pst->selector == ODU_SELECTOR_LC)
42    {
43       /* we are now implemented only light wieght lossely coupled interface */
44       return RFAILED;
45    }
46    else if(pst->selector == ODU_SELECTOR_LWLC)
47    {
48       Buffer *mBuf = NULLP;
49
50       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) 
51       {
52          return RFAILED;
53       }
54
55       /* pack the address of the structure */
56       CMCHKPK(oduPackPointer,(PTR)macCellCfg, mBuf);
57
58       DU_LOG("\nDEBUG  -->  DU-APP : MAC CELL config sent");
59       return ODU_POST_TASK(pst,mBuf);
60    } 
61    return ROK;
62 }
63
64 /**************************************************************************
65  * @brief Function to pack Loose Coupled 
66  *        MAC cell config parameters required by MAC
67  *
68  * @details
69  *
70  *      Function : unpackDuMacCellCfg
71  *
72  *      Functionality:
73  *           packs the macCellCfg parameters
74  *
75  * @param[in] DuMacCellCfgReq func; function pointer
76  * @param[in] Pst     *pst, Post structure of the primitive.
77  * @param[in] Buffer *mBuf
78  * @return ROK     - success
79  *         RFAILED - failure
80  *
81  ***************************************************************************/
82 uint8_t  unpackDuMacCellCfg(DuMacCellCfgReq func, Pst *pst, Buffer *mBuf)
83 {
84    uint16_t ret = ROK;
85    MacCellCfg *macCellCfg;
86
87    if(pst->selector == ODU_SELECTOR_LWLC)
88    {
89       /* unpack the address of the structure */
90       CMCHKUNPK(oduUnpackPointer, (PTR *)&macCellCfg, mBuf);
91       ret = (*func)(pst, macCellCfg);
92    }
93    else
94    {
95       /* only LWLC is implemented now */
96       ret = ROK;
97    }
98
99    return ret;
100 }
101
102 /**************************************************************************
103  * @brief Function to pack Loose Coupled 
104  *        MAC cell config confirm message
105  *
106  * @details
107  *
108  *      Function : packMacCellCfgCfm
109  *
110  *      Functionality:
111  *           packs the transaction ID  
112  *
113  * @param[in] Pst     *pst, Post structure of the primitive.
114  * @param[in] MacCellCfgCfm  *macCellCfgCfm, mac cell config confirm.
115  * @return ROK     - success
116  *         RFAILED - failure
117  *
118  ***************************************************************************/
119 uint8_t  packMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
120 {
121    if(pst->selector == ODU_SELECTOR_LC)
122    {
123       Buffer *mBuf = NULLP;
124       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) 
125       {
126          return RFAILED;
127       }
128
129       /* pack the transaction ID in CNF structure */
130       CMCHKPK(oduUnpackUInt16, macCellCfgCfm->cellId, mBuf);
131       CMCHKPK(oduUnpackUInt8, macCellCfgCfm->rsp, mBuf);
132
133       return ODU_POST_TASK(pst,mBuf);
134    }
135    else if(pst->selector == ODU_SELECTOR_LWLC)
136    {
137       /* only LC is supported */
138       return RFAILED;
139    }
140    return ROK;
141 }
142
143 /**************************************************************************
144  * @brief Function to pack MAC cell config confirm message
145  *
146  * @details
147  *
148  *      Function : unpackMacCellCfgCfm
149  *
150  *      Functionality:
151  *           packs the transaction ID  
152  *
153  * @param[in] DuMacCellCfgCfm func; function pointer
154  * @param[in] Pst     *pst, Post structure of the primitive.
155  * @param[in] Buffer *mBuf
156  * @return ROK     - success
157  *         RFAILED - failure
158  *
159  ***************************************************************************/
160 uint8_t unpackMacCellCfgCfm(DuMacCellCfgCfm func, Pst *pst, Buffer *mBuf)
161 {
162    MacCellCfgCfm macCellCfgCfm;
163
164    if(pst->selector == ODU_SELECTOR_LC)
165    {
166       /* unpack the transaction ID in CNF structure */
167       CMCHKUNPK(oduPackUInt8, &(macCellCfgCfm.rsp), mBuf);
168       CMCHKUNPK(oduPackUInt16, &(macCellCfgCfm.cellId), mBuf);
169       return (*func)(pst, &macCellCfgCfm);
170    }
171    else
172    {
173       /* only loose coupling is suported */
174       return ROK;
175    }
176 }
177
178 /*******************************************************************
179  *
180  * @brief Packs and Send Cell Start Request to MAC
181  *
182  * @details
183  *
184  *    Function : packMacCellStart
185  *
186  *    Functionality:
187  *      Packs and Sends Cell Start Request to MAC
188  *
189  * @params[in] Post structure pointer
190  *             Cell Id
191  * @return ROK     - success
192  *         RFAILED - failure
193  *
194  * ****************************************************************/
195 uint8_t packMacCellStart(Pst *pst, OduCellId *cellId)
196 {
197    Buffer *mBuf = NULLP;
198
199    if(pst->selector == ODU_SELECTOR_LC)
200    {
201       /* Loose coupling not supported */
202       return RFAILED;
203    }
204    else if(pst->selector == ODU_SELECTOR_LWLC)
205    {
206
207       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
208       {
209          DU_LOG("\nERROR  --> DU APP : Memory allocation failed for cell start req pack");
210          return RFAILED;
211       }
212
213       /* pack the address of the structure */
214       CMCHKPK(oduPackPointer,(PTR)cellId, mBuf);
215
216    }
217    return ODU_POST_TASK(pst,mBuf);
218 }
219
220 /*******************************************************************
221  *
222  * @brief Unpacks MAC Cell Start Request from DU APP
223  *
224  * @details
225  *
226  *    Function : unpackMaCellStart
227  *
228  *    Functionality:
229  *      Unpacks MAC Cell Start Request from DU APP
230  *
231  * @params[in] Function pointer of cell start request handler
232  *             Post structure pointer
233  *             Message Buffer
234  * @return ROK     - success
235  *         RFAILED - failure
236  *
237  * ****************************************************************/
238 uint8_t unpackMacCellStart(DuMacCellStart func, Pst *pst, Buffer *mBuf)
239 {
240    OduCellId  *cellId;
241
242    if(pst->selector == ODU_SELECTOR_LWLC)
243    {
244       /* unpack the address of the structure */
245       CMCHKUNPK(oduUnpackPointer, (PTR *)&cellId, mBuf);
246       ODU_PUT_MSG_BUF(mBuf); 
247       return (*func)(pst, cellId);
248    }
249    else
250    {
251       /* Nothing to do for loose coupling */
252       ODU_PUT_MSG_BUF(mBuf);
253       return ROK;
254    }
255 }
256
257 /*******************************************************************
258  *
259  * @brief Packs and Send cell stop request to MAC
260  *
261  * @details
262  *
263  *    Function : packMacCellStop
264  *
265  *    Functionality:
266  *       Packs and Send cell stop request to MAC
267  *
268  * @params[in] Post structure pointer
269  *             Cell Id 
270  * @return ROK     - success
271  *         RFAILED - failure
272  *
273  * ****************************************************************/
274 uint8_t packMacCellStop(Pst *pst, OduCellId  *cellId)
275 {
276    if(pst->selector == ODU_SELECTOR_LC)
277    {
278       /* Loose coupling not supported */
279       return RFAILED;
280    }
281    else if(pst->selector == ODU_SELECTOR_LWLC)
282    {
283       Buffer *mBuf = NULLP;
284
285       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
286       {
287          DU_LOG("\nERROR  --> DU APP : Memory allocation failed for cell stop req pack");
288          return RFAILED;
289       }
290
291       /* pack the address of the structure */
292       CMCHKPK(oduPackPointer,(PTR)cellId, mBuf);
293
294       return ODU_POST_TASK(pst,mBuf);
295    }
296    return ROK;
297 }
298
299 /*******************************************************************
300  *
301  * @brief Unpacks cell stop request from DU APP 
302  *
303  * @details
304  *
305  *    Function : unpackMaCellStop 
306  *
307  *    Functionality:
308  *       Unpacks cell stop request from DU APP 
309  *
310  * @params[in] Handler function pointer
311  *             Post structure pointer
312  *             Message Buffer
313  * @return ROK     - success
314  *         RFAILED - failure
315  *
316  * ****************************************************************/
317 uint8_t unpackMacCellStop(DuMacCellStop func, Pst *pst, Buffer *mBuf)
318 {
319    OduCellId *cellId;
320    
321    if(pst->selector == ODU_SELECTOR_LWLC)
322    {
323       /* unpack the address of the structure */
324       CMCHKUNPK(oduUnpackPointer, (PTR *)&cellId, mBuf);
325       ODU_PUT_MSG_BUF(mBuf);
326       return (*func)(pst, cellId);
327    }
328    else
329    {
330       /* Nothing to do for loose coupling */
331       ODU_PUT_MSG_BUF(mBuf);
332       return ROK;
333    }
334 }
335
336 /*******************************************************************
337  *
338  * @brief Packs and Sends cell up ind from MAC to DUAPP
339  *
340  * @details
341  *
342  *    Function : packMacCellUpInd
343  *
344  *    Functionality:
345  *       Packs and Sends cell up ind from MAC to DUAPP
346  *
347  * @params[in] Post structure pointer
348  *             Cell Id
349  * @return ROK     - success
350  *         RFAILED - failure
351  *
352  * ****************************************************************/
353 uint8_t packMacCellUpInd(Pst *pst, OduCellId *cellId)
354 {
355    Buffer *mBuf = NULLP;
356
357    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
358    {
359       DU_LOG("\nERROR  --> DU APP : Memory allocation failed for packMacCellUpInd");
360       return RFAILED;
361    }
362
363    if(pst->selector == ODU_SELECTOR_LC)
364    {
365       CMCHKPK(oduUnpackUInt16, cellId->cellId, mBuf);
366       CM_FREE_SHRABL_BUF(pst->region, pst->pool, cellId, sizeof(OduCellId));
367       cellId = NULL;
368    }
369    else if(pst->selector == ODU_SELECTOR_LWLC)
370    {
371       /* pack the address of the structure */
372       CMCHKPK(oduPackPointer,(PTR)cellId, mBuf);
373    }
374    else
375    {
376       ODU_PUT_MSG_BUF(mBuf);
377    }
378
379    return ODU_POST_TASK(pst, mBuf);
380 }
381
382 /*******************************************************************
383  *
384  * @brief Unpacks cell up indication from MAC
385  *
386  * @details
387  *
388  *    Function : unpackMacCellUpInd
389  *
390  *    Functionality:
391  *         Unpacks cell up indication from MAC
392  *
393  * @params[in] Pointer to Handler
394  *             Post structure pointer
395  *             Message Buffer
396  * @return ROK     - success
397  *         RFAILED - failure
398  *
399  * ****************************************************************/
400 uint8_t unpackMacCellUpInd(DuMacCellUpInd func, Pst *pst, Buffer *mBuf)
401 {
402    if(pst->selector == ODU_SELECTOR_LWLC)
403    {
404       OduCellId *cellId;
405
406       /* unpack the address of the structure */
407       CMCHKUNPK(oduUnpackPointer, (PTR *)&cellId, mBuf);
408       ODU_PUT_MSG_BUF(mBuf);
409       return (*func)(pst, cellId);
410    }
411    else if(pst->selector == ODU_SELECTOR_LC)
412    {
413       OduCellId cellId;
414       CMCHKUNPK(oduPackUInt16, &cellId.cellId, mBuf);
415       ODU_PUT_MSG_BUF(mBuf);
416       return (*func)(pst, &cellId);
417    }
418    else
419    {
420       /* Nothing to do for loose coupling */
421       ODU_PUT_MSG_BUF(mBuf);
422       return ROK;
423    }
424    return ROK;
425 }
426
427 /*******************************************************************
428  *
429  * @brief Packs and Sends stop ind from MAC to DUAPP
430  *
431  * @details
432  *
433  *    Function : packMacStopInd
434  *
435  *    Functionality:
436  *       Packs and Sends stop ind from MAC to DUAPP
437  *
438  * @params[in] Post structure pointer
439  * @return ROK     - success
440  *         RFAILED - failure
441  *
442  * ****************************************************************/
443 uint8_t packMacStopInd(Pst *pst, OduCellId *cellId)
444 {
445    Buffer *mBuf = NULLP;
446
447    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
448    {
449       DU_LOG("\nERROR  --> DU APP : Memory allocation failed for stop Ind pack");
450       return RFAILED;
451    }
452
453    if(pst->selector == ODU_SELECTOR_LC)
454    {
455       /*pack the payload here*/
456       CMCHKPK(oduUnpackUInt16, cellId->cellId, mBuf);
457       CM_FREE_SHRABL_BUF(pst->region, pst->pool, cellId, sizeof(OduCellId));
458       cellId = NULL;
459    }
460    else if(pst->selector == ODU_SELECTOR_LWLC)
461    {
462       /* pack the address of the structure */
463       CMCHKPK(oduPackPointer,(PTR)cellId, mBuf);
464    }
465    else
466    {
467       ODU_PUT_MSG_BUF(mBuf);
468    }
469
470    return ODU_POST_TASK(pst,mBuf);
471 }
472
473 /*******************************************************************
474  *
475  * @brief Unpacks stop indication from MAC
476  *
477  * @details
478  *
479  *    Function : unpackMacStopInd
480  *
481  *    Functionality:
482  *         Unpacks stop indication from MAC
483  *
484  * @params[in] Pointer to Handler
485  *             Post structure pointer
486  *             Message Buffer
487  * @return ROK     - success
488  *         RFAILED - failure
489  *
490  * ****************************************************************/
491 uint8_t unpackMacStopInd(DuMacStopInd func, Pst *pst, Buffer *mBuf)
492 {
493    if(pst->selector == ODU_SELECTOR_LWLC)
494    {
495       OduCellId *cellId=NULLP;
496       /* unpack the address of the structure */
497       CMCHKUNPK(oduUnpackPointer, (PTR *)&cellId, mBuf);
498       ODU_PUT_MSG_BUF(mBuf);
499       return (*func)(pst, cellId);
500    }
501    else if(pst->selector == ODU_SELECTOR_LC)
502    {
503       OduCellId cellId;
504       CMCHKUNPK(oduPackUInt16, &(cellId.cellId), mBuf);
505
506       ODU_PUT_MSG_BUF(mBuf);
507       return (*func)(pst, &cellId);
508
509    }
510    else
511    {
512       /* Nothing to do for loose coupling */
513       ODU_PUT_MSG_BUF(mBuf);
514       return ROK;
515    }
516    return ROK;
517 }
518
519 /*******************************************************************
520  *
521  * @brief Packs and Sends UL CCCH Ind from MAC to DUAPP
522  *
523  * @details
524  *
525  *    Function : packMacUlCcchInd
526  *
527  *    Functionality:
528  *       Packs and Sends UL CCCH Ind from MAC to DUAPP
529  *
530  * @params[in] Post structure pointer
531  *             UL CCCH Ind pointer              
532  * @return ROK     - success
533  *         RFAILED - failure
534  *
535  * ****************************************************************/
536 uint8_t packMacUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo)
537 {
538    Buffer *mBuf = NULLP;
539
540    if(pst->selector == ODU_SELECTOR_LWLC)
541    {
542       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
543       {
544          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packMacUlCcchInd");
545          return RFAILED;
546       }
547       /* pack the address of the structure */
548       CMCHKPK(oduPackPointer,(PTR)ulCcchIndInfo, mBuf);
549    }
550    else
551    {
552       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for UL CCCH Ind ");
553       return RFAILED;
554    }
555
556    return ODU_POST_TASK(pst,mBuf);
557 }
558
559 /*******************************************************************
560  *
561  * @brief Unpacks UL CCCH indication from MAC
562  *
563  * @details
564  *
565  *    Function : unpackMacUlCcchInd
566  *
567  *    Functionality:
568  *         Unpacks UL CCCH indication from MAC
569  *
570  * @params[in] Pointer to Handler
571  *             Post structure pointer
572  *             Message Buffer
573  * @return ROK     - success
574  *         RFAILED - failure
575  *
576  * ****************************************************************/
577 uint8_t unpackMacUlCcchInd(DuMacUlCcchInd func, Pst *pst, Buffer *mBuf)
578 {
579    if(pst->selector == ODU_SELECTOR_LWLC)
580    {
581       UlCcchIndInfo *ulCcchIndInfo;
582
583       /* unpack the address of the structure */
584       CMCHKUNPK(oduUnpackPointer, (PTR *)&ulCcchIndInfo, mBuf);
585       ODU_PUT_MSG_BUF(mBuf);
586       return (*func)(pst, ulCcchIndInfo);
587    }
588    else
589    {
590       /* Nothing to do for other selectors */
591       DU_LOG("\nERROR  -->  MAC : Only LWLC supported for UL CCCH Ind ");
592       ODU_PUT_MSG_BUF(mBuf);
593    }
594    return RFAILED;
595 }
596
597 /*******************************************************************
598  *
599  * @brief Packs and Sends DL CCCH Ind from DUAPP to MAC
600  *
601  * @details
602  *
603  *    Function : packMacDlCcchInd
604  *
605  *    Functionality:
606  *       Packs and Sends DL CCCH Ind from DUAPP to MAC
607  *
608  *
609  * @params[in] Post structure pointer
610  *             DL CCCH Ind pointer              
611  * @return ROK     - success
612  *         RFAILED - failure
613  *
614  * ****************************************************************/
615 uint8_t packMacDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
616 {
617    Buffer *mBuf = NULLP;
618
619    if(pst->selector == ODU_SELECTOR_LWLC)
620    {
621       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
622       {
623          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packMacDlCcchInd");
624          return RFAILED;
625       }
626       /* pack the address of the structure */
627       CMCHKPK(oduPackPointer,(PTR)dlCcchIndInfo, mBuf);
628    }
629    else
630    {
631       DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for DL CCCH Ind ");
632       return RFAILED;
633    }
634
635    return ODU_POST_TASK(pst,mBuf);
636 }
637
638 /*******************************************************************
639  *
640  * @brief Unpacks DL CCCH indication from DU APP
641  *
642  * @details
643  *
644  *    Function : unpackMacDlCcchInd
645  *
646  *    Functionality:
647  *         Unpacks DL CCCH indication from DU APP
648  *
649  * @params[in] Pointer to Handler
650  *             Post structure pointer
651  *             Message Buffer
652  * @return ROK     - success
653  *         RFAILED - failure
654  *
655  * ****************************************************************/
656 uint8_t unpackMacDlCcchInd(DuMacDlCcchInd func, Pst *pst, Buffer *mBuf)
657 {
658    if(pst->selector == ODU_SELECTOR_LWLC)
659    {
660       DlCcchIndInfo *dlCcchIndInfo;
661
662       /* unpack the address of the structure */
663       CMCHKUNPK(oduUnpackPointer, (PTR *)&dlCcchIndInfo, mBuf);
664       ODU_PUT_MSG_BUF(mBuf);
665       return (*func)(pst, dlCcchIndInfo);
666    }
667    else
668    {
669       /* Nothing to do for other selectors */
670       DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for DL CCCH Ind ");
671       ODU_PUT_MSG_BUF(mBuf);
672    }
673
674    return RFAILED;
675 }
676
677 /*******************************************************************
678  *
679  * @brief Packs and Sends UE create Request from DUAPP to MAC
680  *
681  * @details
682  *
683  *    Function : packDuMacUeCreateReq
684  *
685  *    Functionality:
686  *       Packs and Sends UE Create Request from DUAPP to MAC
687  *
688  *
689  * @params[in] Post structure pointer
690  *             MacUeCfg pointer              
691  * @return ROK     - success
692  *         RFAILED - failure
693  *
694  * ****************************************************************/
695 uint8_t packDuMacUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
696 {
697    Buffer *mBuf = NULLP;
698
699    if(pst->selector == ODU_SELECTOR_LWLC)
700    {
701       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
702       {
703          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacUeCreateReq");
704          return RFAILED;
705       }
706       /* pack the address of the structure */
707       CMCHKPK(oduPackPointer,(PTR)ueCfg, mBuf);
708    }
709    else
710    {
711       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacUeCreateReq");
712       return RFAILED;
713    }
714
715    return ODU_POST_TASK(pst,mBuf);
716 }
717
718 /*******************************************************************
719  *
720  * @brief Unpacks UE Create Request received from DU APP
721  *
722  * @details
723  *
724  *    Function : unpackMacUeCreateReq
725  *
726  *    Functionality:
727  *         Unpacks UE Create Request received from DU APP
728  *
729  * @params[in] Pointer to Handler
730  *             Post structure pointer
731  *             Message Buffer
732  * @return ROK     - success
733  *         RFAILED - failure
734  *
735  * ****************************************************************/
736 uint8_t unpackMacUeCreateReq(DuMacUeCreateReq func, Pst *pst, Buffer *mBuf)
737 {
738    if(pst->selector == ODU_SELECTOR_LWLC)
739    {
740       MacUeCfg *ueCfg;
741
742       /* unpack the address of the structure */
743       CMCHKUNPK(oduUnpackPointer, (PTR *)&ueCfg, mBuf);
744       ODU_PUT_MSG_BUF(mBuf);
745       return (*func)(pst, ueCfg);
746    }
747    else
748    {
749       /* Nothing to do for other selectors */
750       DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for UE Create Request ");
751       ODU_PUT_MSG_BUF(mBuf);
752    }
753
754    return RFAILED;
755 }
756
757 /*******************************************************************
758  *
759  * @brief Pack and send UE config response from MAC to DU APP
760  *
761  * @details
762  *
763  *    Function : packDuMacUeCfgRsp
764  *
765  *    Functionality:
766  *       Pack and send UE config response from MAC to DU APP
767  *
768  * @params[in] 
769  * @return ROK     - success
770  *         RFAILED - failure
771  *
772  * ****************************************************************/
773 uint8_t packDuMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
774 {
775    Buffer *mBuf = NULLP;
776
777    if(pst->selector == ODU_SELECTOR_LWLC)
778    {
779       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
780       {
781          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacUeCfgRsp");
782          return RFAILED;
783       }
784       /* pack the address of the structure */
785       CMCHKPK(oduPackPointer,(PTR)cfgRsp, mBuf);
786    }
787    else
788    {
789       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacUeCfgRsp");
790       return RFAILED;
791    }
792
793    return ODU_POST_TASK(pst,mBuf);
794 }
795 /*******************************************************************
796  *
797  * @brief Unpack UE Config Response from MAC to DU APP
798  *
799  * @details
800  *
801  *    Function :unpackDuMacUeCfgRsp 
802  *
803  *    Functionality: Unpack UE Config Response from MAC to DU APP
804  *
805  * @params[in] 
806  * @return ROK     - success
807  *         RFAILED - failure
808  *
809  * ****************************************************************/
810 uint8_t unpackDuMacUeCfgRsp(MacDuUeCfgRspFunc func, Pst *pst, Buffer *mBuf)
811 {
812    if(pst->selector == ODU_SELECTOR_LWLC)
813    {
814       MacUeCfgRsp *cfgRsp = NULLP;
815
816       /* unpack the address of the structure */
817       CMCHKUNPK(oduUnpackPointer, (PTR *)&cfgRsp, mBuf);
818       ODU_PUT_MSG_BUF(mBuf);
819       return (*func)(pst, cfgRsp);
820    }
821
822    ODU_PUT_MSG_BUF(mBuf);
823    return RFAILED;
824 }
825
826 /*******************************************************************
827  *
828  * @brief Packs and Sends UE Reconig Request from DUAPP to MAC
829  *
830  * @details
831  *
832  *    Function : packDuMacUeReconfigReq
833  *
834  *    Functionality:
835  *       Packs and Sends UE Reconfig Request from DUAPP to MAC
836  *
837  *
838  * @params[in] Post structure pointer
839  *             MacUeCfg pointer              
840  * @return ROK     - success
841  *         RFAILED - failure
842  *
843  * ****************************************************************/
844 uint8_t packDuMacUeReconfigReq(Pst *pst, MacUeCfg *ueCfg)
845 {
846    Buffer *mBuf = NULLP;
847
848    if(pst->selector == ODU_SELECTOR_LWLC)
849    {
850       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
851       {
852          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacUeReconfigReq");
853          return RFAILED;
854       }
855       /* pack the address of the structure */
856       CMCHKPK(oduPackPointer,(PTR)ueCfg, mBuf);
857    }
858    else
859    {
860       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacUeReconfigReq");
861       return RFAILED;
862    }
863
864    return ODU_POST_TASK(pst,mBuf);
865 }
866
867 /*******************************************************************
868  *
869  * @brief Unpacks UE Reconfig Request received from DU APP
870  *
871  * @details
872  *
873  *    Function : unpackMacUeReconfigReq
874  *
875  *    Functionality:
876  *         Unpacks UE Reconfig Request received from DU APP
877  *
878  * @params[in] Pointer to Handler
879  *             Post structure pointer
880  *             Message Buffer
881  * @return ROK     - success
882  *         RFAILED - failure
883  *
884  * ****************************************************************/
885 uint8_t unpackMacUeReconfigReq(DuMacUeReconfigReq func, Pst *pst, Buffer *mBuf)
886 {
887    if(pst->selector == ODU_SELECTOR_LWLC)
888    {
889       MacUeCfg *ueCfg;
890
891       /* unpack the address of the structure */
892       CMCHKUNPK(oduUnpackPointer, (PTR *)&ueCfg, mBuf);
893       ODU_PUT_MSG_BUF(mBuf);
894       return (*func)(pst, ueCfg);
895    }
896    else
897    {
898       /* Nothing to do for other selectors */
899       DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for UE Create Request ");
900       ODU_PUT_MSG_BUF(mBuf);
901    }
902
903    return RFAILED;
904 }
905
906 /*******************************************************************
907  *
908  * @brief Packs and Sends RACH Resource request from DUAPP to MAC
909  *
910  * @details
911  *
912  *    Function : packDuMacRachRsrcReq
913  *
914  *    Functionality:
915  *       Packs and Sends RACH Resource request from DU APP to MAC
916  *
917  *
918  * @params[in] Post structure pointer
919  *             MacRachRsrcReq pointer              
920  * @return ROK     - success
921  *         RFAILED - failure
922  *
923  * ****************************************************************/
924 uint8_t packDuMacRachRsrcReq(Pst *pst, MacRachRsrcReq *rachRsrcReq)
925 {
926    Buffer *mBuf = NULLP;
927
928    if(pst->selector == ODU_SELECTOR_LWLC)
929    {
930       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
931       {
932          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacRachRsrcReq,");
933          return RFAILED;
934       }
935       /* pack the address of the structure */
936       CMCHKPK(oduPackPointer, (PTR)rachRsrcReq, mBuf);
937    }
938    else
939    {
940       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacRachRsrcReq");
941       return RFAILED;
942    }
943
944    return ODU_POST_TASK(pst,mBuf);
945 }
946
947 /*******************************************************************
948  *
949  * @brief Unpacks RACH resource Request received from DU APP
950  *
951  * @details
952  *
953  *    Function : unpackMacRachRsrcReq
954  *
955  *    Functionality:
956  *         Unpacks RACH resource Request received from DU APP
957  *
958  * @params[in] Pointer to Handler
959  *             Post structure pointer
960  *             Message Buffer
961  * @return ROK     - success
962  *         RFAILED - failure
963  *
964  * ****************************************************************/
965 uint8_t unpackMacRachRsrcReq(DuMacRachRsrcReq func, Pst *pst, Buffer *mBuf)
966 {
967    if(pst->selector == ODU_SELECTOR_LWLC)
968    {
969       MacRachRsrcReq *rachRsrcReq;
970
971       /* unpack the address of the structure */
972       CMCHKUNPK(oduUnpackPointer, (PTR *)&rachRsrcReq, mBuf);
973       ODU_PUT_MSG_BUF(mBuf);
974       return (*func)(pst, rachRsrcReq);
975    }
976    else
977    {
978       /* Nothing to do for other selectors */
979       DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for RACH resource Request ");
980       ODU_PUT_MSG_BUF(mBuf);
981    }
982
983    return RFAILED;
984 }
985
986 /*******************************************************************
987  *
988  * @brief Packs and Sends RACH Resource release from DUAPP to MAC
989  *
990  * @details
991  *
992  *    Function : packDuMacRachRsrcRel
993  *
994  *    Functionality:
995  *       Packs and Sends RACH Resource release from DU APP to MAC
996  *
997  *
998  * @params[in] Post structure pointer
999  *             MacRachRsrcRel pointer              
1000  * @return ROK     - success
1001  *         RFAILED - failure
1002  *
1003  * ****************************************************************/
1004 uint8_t packDuMacRachRsrcRel(Pst *pst, MacRachRsrcRel *rachRsrcRel)
1005 {
1006    Buffer *mBuf = NULLP;
1007
1008    if(pst->selector == ODU_SELECTOR_LWLC)
1009    {
1010       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
1011       {
1012          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacRachRsrcRel");
1013          return RFAILED;
1014       }
1015       /* pack the address of the structure */
1016       CMCHKPK(oduPackPointer, (PTR)rachRsrcRel, mBuf);
1017    }
1018    else
1019    {
1020       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacRachRsrcRel");
1021       return RFAILED;
1022    }
1023
1024    return ODU_POST_TASK(pst,mBuf);
1025 }
1026
1027 /*******************************************************************
1028  *
1029  * @brief Unpacks RACH Resource Release received from DU APP
1030  *
1031  * @details
1032  *
1033  *    Function : unpackMacRachRsrcRel
1034  *
1035  *    Functionality:
1036  *         Unpacks RACH Resource Release received from DU APP
1037  *
1038  * @params[in] Pointer to Handler
1039  *             Post structure pointer
1040  *             Message Buffer
1041  * @return ROK     - success
1042  *         RFAILED - failure
1043  *
1044  * ****************************************************************/
1045 uint8_t unpackMacRachRsrcRel(DuMacRachRsrcRel func, Pst *pst, Buffer *mBuf)
1046 {
1047    if(pst->selector == ODU_SELECTOR_LWLC)
1048    {
1049       MacRachRsrcRel *rachRsrcRel;
1050
1051       /* unpack the address of the structure */
1052       CMCHKUNPK(oduUnpackPointer, (PTR *)&rachRsrcRel, mBuf);
1053       ODU_PUT_MSG_BUF(mBuf);
1054       return (*func)(pst, rachRsrcRel);
1055    }
1056    else
1057    {
1058       /* Nothing to do for other selectors */
1059       DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for RACH Resource Release ");
1060       ODU_PUT_MSG_BUF(mBuf);
1061    }
1062
1063    return RFAILED;
1064 }
1065
1066 /*******************************************************************
1067  *
1068  * @brief Packs and Sends RACH Resource response from MAC to DU APP
1069  *
1070  * @details
1071  *
1072  *    Function : packDuMacRachRsrcRsp
1073  *
1074  *    Functionality:
1075  *       Packs and Sends RACH Resource response from MAC to DU APP
1076  *
1077  *
1078  * @params[in] Post structure pointer
1079  *             MacRachRsrcRsp pointer              
1080  * @return ROK     - success
1081  *         RFAILED - failure
1082  *
1083  * ****************************************************************/
1084 uint8_t packDuMacRachRsrcRsp(Pst *pst, MacRachRsrcRsp *rachRsrcRsp)
1085 {
1086    Buffer *mBuf = NULLP;
1087
1088    if(pst->selector == ODU_SELECTOR_LWLC)
1089    {
1090       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
1091       {
1092          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacRachRsrcRsp");
1093          return RFAILED;
1094       }
1095       /* pack the address of the structure */
1096       CMCHKPK(oduPackPointer, (PTR)rachRsrcRsp, mBuf);
1097    }
1098    else
1099    {
1100       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacRachRsrcRsp");
1101       return RFAILED;
1102    }
1103
1104    return ODU_POST_TASK(pst,mBuf);
1105 }
1106
1107 /*******************************************************************
1108  *
1109  * @brief Unpacks RACH resource Response received from MAC
1110  *
1111  * @details
1112  *
1113  *    Function : unpackDuMacRachRsrcRsp
1114  *
1115  *    Functionality:
1116  *         Unpacks RACH resource Response received from MAC
1117  *
1118  * @params[in] Pointer to Handler
1119  *             Post structure pointer
1120  *             Message Buffer
1121  * @return ROK     - success
1122  *         RFAILED - failure
1123  *
1124  * ****************************************************************/
1125 uint8_t unpackDuMacRachRsrcRsp(MacDuRachRsrcRspFunc func, Pst *pst, Buffer *mBuf)
1126 {
1127    if(pst->selector == ODU_SELECTOR_LWLC)
1128    {
1129       MacRachRsrcRsp *rachRsrcRsp;
1130
1131       /* unpack the address of the structure */
1132       CMCHKUNPK(oduUnpackPointer, (PTR *)&rachRsrcRsp, mBuf);
1133       ODU_PUT_MSG_BUF(mBuf);
1134       return (*func)(pst, rachRsrcRsp);
1135    }
1136    else
1137    {
1138       /* Nothing to do for other selectors */
1139       DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for RACH resource Response ");
1140       ODU_PUT_MSG_BUF(mBuf);
1141    }
1142
1143    return RFAILED;
1144 }
1145 /*******************************************************************
1146 *
1147 * @brief Packs and Sends UE Delete Request from DUAPP to MAC
1148 *
1149 * @details
1150 *
1151 *    Function : packDuMacUeDeleteReq
1152 *
1153 *    Functionality:
1154 *       Packs and Sends UE Delete Request from DUAPP to MAC
1155 *
1156 *
1157 * @params[in] Post structure pointer
1158 *             MacUeDelete pointer
1159 * @return ROK     - success
1160 *         RFAILED - failure
1161 *
1162 * ****************************************************************/
1163 uint8_t packDuMacUeDeleteReq(Pst *pst, MacUeDelete *ueDel)
1164 {
1165     Buffer *mBuf = NULLP;
1166
1167     if(pst->selector == ODU_SELECTOR_LWLC)
1168     {
1169        if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
1170        {
1171           DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacUeDeleteReq");
1172           return RFAILED;
1173        }
1174        /* pack the address of the structure */
1175        CMCHKPK(oduPackPointer,(PTR)ueDel, mBuf);
1176     }
1177     else
1178     {
1179        DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacUeDeleteReq");
1180        return RFAILED;
1181     }
1182
1183     return ODU_POST_TASK(pst,mBuf);
1184 }
1185 /*******************************************************************
1186 *
1187 * @brief Unpacks UE Delete Request received from DU APP
1188 *
1189 * @details
1190 *
1191 *    Function : unpackMacUeDeleteReq 
1192 *
1193 *    Functionality:
1194 *         Unpacks UE Delete Request received from DU APP
1195 *
1196 * @params[in] Pointer to Handler
1197 *             Post structure pointer
1198 *             Message Buffer
1199 * @return ROK     - success
1200 *         RFAILED - failure
1201 *
1202 * ****************************************************************/
1203 uint8_t unpackMacUeDeleteReq(DuMacUeDeleteReq func, Pst *pst, Buffer *mBuf)
1204 {
1205     if(pst->selector == ODU_SELECTOR_LWLC)
1206     {
1207        MacUeDelete *ueDelete;
1208
1209        /* unpack the address of the structure */
1210        CMCHKUNPK(oduUnpackPointer, (PTR *)&ueDelete, mBuf);
1211        ODU_PUT_MSG_BUF(mBuf);
1212        return (*func)(pst, ueDelete);
1213     }
1214     else
1215     {
1216        /* Nothing to do for other selectors */
1217        DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for UE Delete Request ");
1218        ODU_PUT_MSG_BUF(mBuf);
1219     }
1220
1221     return RFAILED;
1222 }
1223 /*******************************************************************
1224  *
1225  * @brief Pack and send UE delete response from MAC to DU APP
1226  *
1227  * @details
1228  *
1229  *    Function : packDuMacUeDeleteRsp
1230  *
1231  *    Functionality:
1232  *       Pack and send UE  delete response from MAC to DU APP
1233  *
1234  * @params[in]
1235  * @return ROK     - success
1236  *         RFAILED - failure
1237  *
1238  * ****************************************************************/
1239 uint8_t packDuMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
1240 {
1241    Buffer *mBuf = NULLP;
1242    
1243    if(pst->selector == ODU_SELECTOR_LWLC)
1244    {
1245       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
1246       {
1247          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacUeDeleteRsp");
1248          return RFAILED;
1249       }
1250       /* pack the address of the structure */
1251       CMCHKPK(oduPackPointer,(PTR)deleteRsp, mBuf);
1252    }
1253    else
1254    {
1255       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacUeDeleteRsp");
1256       return RFAILED;
1257    }
1258    
1259    return ODU_POST_TASK(pst,mBuf);
1260    
1261 }
1262
1263 /*******************************************************************
1264 *
1265 * @brief Unpack UE Config Response from MAC to DU APP
1266 *
1267 * @details
1268 *
1269 *    Function :unpackDuMacUeDeleteRsp 
1270 *
1271 *    Functionality: Unpack UE Config Response from MAC to DU APP
1272 *
1273 * @params[in]
1274 * @return ROK     - success
1275 *         RFAILED - failure
1276 *
1277 * ****************************************************************/
1278 uint8_t unpackDuMacUeDeleteRsp(MacDuUeDeleteRspFunc func, Pst *pst, Buffer *mBuf)
1279 {
1280     if(pst->selector == ODU_SELECTOR_LWLC)
1281     {
1282        MacUeDeleteRsp *ueDeleteRsp = NULLP;
1283
1284        /* unpack the address of the structure */
1285        CMCHKUNPK(oduUnpackPointer, (PTR *)&ueDeleteRsp, mBuf);
1286        ODU_PUT_MSG_BUF(mBuf);
1287        return (*func)(pst, ueDeleteRsp);
1288     }
1289
1290     ODU_PUT_MSG_BUF(mBuf);
1291     return RFAILED;
1292 }
1293
1294 /*******************************************************************
1295  *
1296  * @brief Unpacks Cell Delete Request received from DU APP
1297  *
1298  * @details
1299  *
1300  *    Function : unpackMacCellDeleteReq
1301  *
1302  *    Functionality:
1303  *         Unpacks Cell Delete Request received from DU APP
1304  *
1305  * @params[in] Pointer to Handler
1306  *             Post structure pointer
1307  *             Message Buffer
1308  * @return ROK     - success
1309  *         RFAILED - failure
1310  *
1311  * ****************************************************************/
1312
1313 uint8_t unpackMacCellDeleteReq(DuMacCellDeleteReq func, Pst *pst, Buffer *mBuf)
1314 {
1315    if(pst->selector == ODU_SELECTOR_LWLC)
1316    {
1317       MacCellDelete *cellDelete=NULLP;
1318
1319       /* unpack the address of the structure */
1320       CMCHKUNPK(oduUnpackPointer, (PTR *)&cellDelete, mBuf);
1321       ODU_PUT_MSG_BUF(mBuf);
1322       return (*func)(pst, cellDelete);
1323    }
1324    else
1325    {
1326       /* Nothing to do for other
1327        * selectors */
1328       DU_LOG("\nERROR  -->  DU APP : unpackMacCellDeleteReq(): Only LWLC supported for CELL Delete Request ");
1329       ODU_PUT_MSG_BUF(mBuf);
1330    }
1331
1332    return RFAILED;
1333 }
1334
1335 /*******************************************************************
1336  *
1337  * @brief Pack and send Cell delete request to MAC
1338  *
1339  * @details
1340  *
1341  *    Function : packDuMacCellDeleteReq
1342  *
1343  *    Functionality:
1344  *       Pack and send Cell delete request to MAC
1345  *
1346  * @params[in] Post structure
1347  *             MacCellDelete *cellDelete;
1348  * @return ROK     - success
1349  *         RFAILED - failure
1350  *
1351  * ****************************************************************/
1352
1353 uint8_t packDuMacCellDeleteReq(Pst *pst, MacCellDelete *cellDelete)
1354 {
1355    Buffer *mBuf = NULLP;
1356
1357    if(pst->selector == ODU_SELECTOR_LWLC)
1358    {
1359       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
1360       {
1361          DU_LOG("\nERROR  --> MAC : packDuMacCellDeleteReq(): Memory allocation failed ");
1362          return RFAILED;
1363       }
1364       CMCHKPK(oduPackPointer,(PTR)cellDelete, mBuf);
1365       return ODU_POST_TASK(pst,mBuf);
1366    }
1367    else
1368    {
1369       DU_LOG("\nERROR  -->  MAC: packDuMacCellDeleteReq(): Only LWLC supported ");
1370    }
1371    return RFAILED;
1372 }
1373
1374 /*******************************************************************
1375  *
1376  * @brief Pack and send CELL delete response from MAC to DU APP
1377  *
1378  * @details
1379  *
1380  *    Function : packDuMacCellDeleteRsp
1381  *
1382  *    Functionality:
1383  *       Pack and send CELL  delete response from MAC to DU APP
1384  *
1385  * @params[in] Pst *pst, MacCellDeleteRsp *deleteRsp
1386  * @return ROK     - success
1387  *         RFAILED - failure
1388  *
1389  * ****************************************************************/
1390
1391 uint8_t packDuMacCellDeleteRsp(Pst *pst, MacCellDeleteRsp *cellDeleteRsp)
1392 {
1393    Buffer *mBuf = NULLP;
1394
1395    if(pst->selector == ODU_SELECTOR_LWLC)
1396    {
1397       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
1398       {
1399          DU_LOG("\nERROR  --> MAC : packDuMacCellDeleteRsp(): Memory allocation failed ");
1400          return RFAILED;
1401       }
1402       CMCHKPK(oduPackPointer,(PTR)cellDeleteRsp, mBuf);
1403    }
1404    else
1405    {
1406       DU_LOG("\nERROR  -->  MAC: packDuMacCellDeleteRsp(): Only LWLC supported ");
1407       return RFAILED;
1408    }
1409
1410    return ODU_POST_TASK(pst,mBuf);
1411
1412 }
1413
1414 /*******************************************************************
1415  *
1416  * @brief Unpack cell delete response from MAC to DU APP
1417  *
1418  * @details
1419  *
1420  *    Function : unpackDuMacCellDeleteRsp
1421  *
1422  *    Functionality: Unpack cell delete response from MAC to DU APP
1423  *
1424  * @params[in] MacDuCellDeleteRspFunc func, Pst *pst, Buffer *mBuf
1425  * @return ROK     - success
1426  *         RFAILED - failure
1427  *
1428  * ****************************************************************/
1429
1430 uint8_t unpackDuMacCellDeleteRsp(MacDuCellDeleteRspFunc func, Pst *pst, Buffer *mBuf)
1431 {
1432    if(pst->selector == ODU_SELECTOR_LWLC)
1433    {
1434       MacCellDeleteRsp *cellDeleteRsp = NULLP;
1435
1436       CMCHKUNPK(oduUnpackPointer, (PTR *)&cellDeleteRsp, mBuf);
1437       ODU_PUT_MSG_BUF(mBuf);
1438       return (*func)(pst, cellDeleteRsp);
1439    }
1440    else
1441    {  
1442       DU_LOG("\nERROR  -->  DU APP : unpackDuMacCellDeleteRsp(): Only LWLC supported ");
1443       ODU_PUT_MSG_BUF(mBuf);
1444    }
1445    return RFAILED;
1446 }
1447
1448 /*******************************************************************
1449  *
1450  * @brief Pack and send Slice Cfg request from MAC to DU APP
1451  *
1452  * @details
1453  *
1454  *    Function : packDuMacSliceCfgReq
1455  *
1456  *    Functionality:
1457  *       Pack and send Slice Cfg request from MAC to DU APP
1458  *
1459  * @params[in] Pst *pst, MacSliceCfgReq *sliceCfgReq
1460  * @return ROK     - success
1461  *         RFAILED - failure
1462  *
1463  * ****************************************************************/
1464
1465 uint8_t packDuMacSliceCfgReq(Pst *pst, MacSliceCfgReq *sliceCfgReq)
1466 {
1467    Buffer *mBuf = NULLP;
1468
1469    if(pst->selector == ODU_SELECTOR_LWLC)
1470    {
1471       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
1472       {
1473          DU_LOG("\nERROR  --> MAC : Memory allocation failed in packDuMacSliceCfgReq");
1474          return RFAILED;
1475       }
1476       CMCHKPK(oduPackPointer,(PTR)sliceCfgReq, mBuf);
1477    }
1478    else
1479    {
1480       DU_LOG("\nERROR  -->  MAC: Only LWLC supported in packDuMacSliceCfgReq");
1481       return RFAILED;
1482    }
1483
1484    return ODU_POST_TASK(pst,mBuf);
1485
1486 }
1487 /*******************************************************************
1488 *
1489 * @brief Unpacks Slice Cfg request received from DU APP
1490 *
1491 * @details
1492 *
1493 *    Function : unpackMacSliceCfgReq 
1494 *
1495 *    Functionality:
1496 *         Unpacks Slice Cfg Request received from DU APP
1497 *
1498 * @params[in] Pointer to Handler
1499 *             Post structure pointer
1500 *             Message Buffer
1501 * @return ROK     - success
1502 *         RFAILED - failure
1503 *
1504 * ****************************************************************/
1505 uint8_t unpackMacSliceCfgReq(DuMacSliceCfgReq func, Pst *pst, Buffer *mBuf)
1506 {
1507     if(pst->selector == ODU_SELECTOR_LWLC)
1508     {
1509        MacSliceCfgReq *sliceCfgReq;
1510        /* unpack the address of the structure */
1511        CMCHKUNPK(oduUnpackPointer, (PTR *)&sliceCfgReq, mBuf);
1512        ODU_PUT_MSG_BUF(mBuf);
1513        return (*func)(pst, sliceCfgReq);
1514     }
1515     else
1516     {
1517        /* Nothing to do for other selectors */
1518        DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for Slice Cfg Request ");
1519        ODU_PUT_MSG_BUF(mBuf);
1520     }
1521
1522     return RFAILED;
1523 }
1524
1525 /*******************************************************************
1526  *
1527  * @brief Pack and send Slice config response from MAC to DU APP
1528  *
1529  * @details
1530  *
1531  *    Function : packDuMacSliceCfgRsp
1532  *
1533  *    Functionality:
1534  *       Pack and send Slice config response from MAC to DU APP
1535  *
1536  * @params[in] 
1537  * @return ROK     - success
1538  *         RFAILED - failure
1539  *
1540  * ****************************************************************/
1541 uint8_t packDuMacSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp)
1542 {
1543    Buffer *mBuf = NULLP;
1544
1545    if(pst->selector == ODU_SELECTOR_LWLC)
1546    {
1547       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
1548       {
1549          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacSliceCfgRsp");
1550          return RFAILED;
1551       }
1552       /* pack the address of the structure */
1553       CMCHKPK(oduPackPointer,(PTR)cfgRsp, mBuf);
1554    }
1555    else
1556    {
1557       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacSliceCfgRsp");
1558       return RFAILED;
1559    }
1560
1561    return ODU_POST_TASK(pst,mBuf);
1562 }
1563
1564 /*******************************************************************
1565  *
1566  * @brief Unpack Slice Config Response from MAC to DU APP
1567  *
1568  * @details
1569  *
1570  *    Function :unpackDuMacSliceCfgRsp 
1571  *
1572  *    Functionality: Unpack Slice Config Response from MAC to DU APP
1573  *
1574  * @params[in] 
1575  * @return ROK     - success
1576  *         RFAILED - failure
1577  *
1578  * ****************************************************************/
1579 uint8_t unpackDuMacSliceCfgRsp(MacDuSliceCfgRspFunc func, Pst *pst, Buffer *mBuf)
1580 {
1581    if(pst->selector == ODU_SELECTOR_LWLC)
1582    {
1583       MacSliceCfgRsp *cfgRsp = NULLP;
1584
1585       /* unpack the address of the structure */
1586       CMCHKUNPK(oduUnpackPointer, (PTR *)&cfgRsp, mBuf);
1587       ODU_PUT_MSG_BUF(mBuf);
1588       return (*func)(pst, cfgRsp);
1589    }
1590
1591    ODU_PUT_MSG_BUF(mBuf);
1592    return RFAILED;
1593 }
1594
1595
1596 /*******************************************************************
1597  *
1598  * @brief Pack and send Slice ReCfg request from MAC to DU APP
1599  *
1600  * @details
1601  *
1602  *    Function : packDuMacSliceRecfgReq
1603  *
1604  *    Functionality:
1605  *       Pack and send Slice ReCfg request from MAC to DU APP
1606  *
1607  * @params[in] Pst *pst, MacSliceCfgReq *sliceReCfgReq
1608  * @return ROK     - success
1609  *         RFAILED - failure
1610  *
1611  * ****************************************************************/
1612
1613 uint8_t packDuMacSliceRecfgReq(Pst *pst, MacSliceCfgReq *sliceReCfgReq)
1614 {
1615    Buffer *mBuf = NULLP;
1616
1617    if(pst->selector == ODU_SELECTOR_LWLC)
1618    {
1619       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
1620       {
1621          DU_LOG("\nERROR  --> MAC : Memory allocation failed in packDuMacSliceRecfgReq");
1622          return RFAILED;
1623       }
1624       CMCHKPK(oduPackPointer,(PTR)sliceReCfgReq, mBuf);
1625    }
1626    else
1627    {
1628       DU_LOG("\nERROR  -->  MAC: Only LWLC supported in packDuMacSliceRecfgReq");
1629       return RFAILED;
1630    }
1631
1632    return ODU_POST_TASK(pst,mBuf);
1633
1634 }
1635 /*******************************************************************
1636 *
1637 * @brief Unpacks Slice ReCfg request received from DU APP
1638 *
1639 * @details
1640 *
1641 *    Function : unpackMacSliceCfgReq 
1642 *
1643 *    Functionality:
1644 *         Unpacks Slice ReCfg Request received from DU APP
1645 *
1646 * @params[in] Pointer to Handler
1647 *             Post structure pointer
1648 *             Message Buffer
1649 * @return ROK     - success
1650 *         RFAILED - failure
1651 *
1652 * ****************************************************************/
1653 uint8_t unpackMacSliceReCfgReq(DuMacSliceRecfgReq func, Pst *pst, Buffer *mBuf)
1654 {
1655     if(pst->selector == ODU_SELECTOR_LWLC)
1656     {
1657        MacSliceCfgReq *sliceReCfgReq;
1658        /* unpack the address of the structure */
1659        CMCHKUNPK(oduUnpackPointer, (PTR *)&sliceReCfgReq, mBuf);
1660        ODU_PUT_MSG_BUF(mBuf);
1661        return (*func)(pst, sliceReCfgReq);
1662     }
1663     else
1664     {
1665        /* Nothing to do for other selectors */
1666        DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for Slice ReCfg Request ");
1667        ODU_PUT_MSG_BUF(mBuf);
1668     }
1669
1670     return RFAILED;
1671 }
1672
1673 /*******************************************************************
1674  *
1675  * @brief Pack and send Slice config response from MAC to DU APP
1676  *
1677  * @details
1678  *
1679  *    Function : packDuMacSliceReCfgRsp
1680  *
1681  *    Functionality:
1682  *       Pack and send Slice config response from MAC to DU APP
1683  *
1684  * @params[in] 
1685  * @return ROK     - success
1686  *         RFAILED - failure
1687  *
1688  * ****************************************************************/
1689 uint8_t packDuMacSliceReCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp)
1690 {
1691    Buffer *mBuf = NULLP;
1692
1693    if(pst->selector == ODU_SELECTOR_LWLC)
1694    {
1695       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
1696       {
1697          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacSliceReCfgRsp");
1698          return RFAILED;
1699       }
1700       /* pack the address of the structure */
1701       CMCHKPK(oduPackPointer,(PTR)cfgRsp, mBuf);
1702    }
1703    else
1704    {
1705       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacSliceReCfgRsp");
1706       return RFAILED;
1707    }
1708
1709    return ODU_POST_TASK(pst,mBuf);
1710 }
1711
1712 /*******************************************************************
1713  *
1714  * @brief Unpack Slice ReConfig Response from MAC to DU APP
1715  *
1716  * @details
1717  *
1718  *    Function :unpackDuMacSliceReCfgRsp 
1719  *
1720  *    Functionality: Unpack Slice ReConfig Response from MAC to DU APP
1721  *
1722  * @params[in] 
1723  * @return ROK     - success
1724  *         RFAILED - failure
1725  *
1726  * ****************************************************************/
1727 uint8_t unpackDuMacSliceReCfgRsp(MacDuSliceReCfgRspFunc func, Pst *pst, Buffer *mBuf)
1728 {
1729    if(pst->selector == ODU_SELECTOR_LWLC)
1730    {
1731       MacSliceCfgRsp *cfgRsp = NULLP;
1732
1733       /* unpack the address of the structure */
1734       CMCHKUNPK(oduUnpackPointer, (PTR *)&cfgRsp, mBuf);
1735       ODU_PUT_MSG_BUF(mBuf);
1736       return (*func)(pst, cfgRsp);
1737    }
1738
1739    ODU_PUT_MSG_BUF(mBuf);
1740    return RFAILED;
1741 }
1742
1743 /*******************************************************************
1744  *
1745  * @brief Pack and send Slot ind from MAC to DU APP
1746  *
1747  * @details
1748  *
1749  *    Function : packMacSlotInd
1750  *
1751  *    Functionality:
1752  *       Pack and send Slot ind from MAC to DU APP
1753  *
1754  * @params[in] Pst *pst, SlotTimingInfo *slotIndInfo 
1755  * @return ROK     - success
1756  *         RFAILED - failure
1757  *
1758  * ****************************************************************/
1759 uint8_t packMacSlotInd(Pst *pst, SlotTimingInfo *slotIndInfo)
1760 {
1761    Buffer *mBuf = NULLP;
1762
1763    if(pst->selector == ODU_SELECTOR_LWLC)
1764    {
1765       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
1766       {
1767          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packMacSlotInd");
1768          return RFAILED;
1769       }
1770       /* pack the address of the structure */
1771       CMCHKPK(oduPackPointer,(PTR)slotIndInfo, mBuf);
1772    }
1773    else
1774    {
1775       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packMacSlotInd");
1776       return RFAILED;
1777    }
1778
1779    return ODU_POST_TASK(pst,mBuf);
1780 }
1781
1782 /*******************************************************************
1783  *
1784  * @brief Unpack Slot indication from MAC to DU APP
1785  *
1786  * @details
1787  *
1788  *    Function :unpackDuMacSlotInd 
1789  *
1790  *    Functionality: Unpack Slot Indication from MAC to DU APP
1791  *
1792  * @params[in] DuMacSlotInd func, Pst *pst, Buffer *mBuf 
1793  * @return ROK     - success
1794  *         RFAILED - failure
1795  *
1796  * ****************************************************************/
1797 uint8_t unpackDuMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf)
1798 {
1799    if(pst->selector == ODU_SELECTOR_LWLC)
1800    {
1801       SlotTimingInfo *slotIndInfo;
1802       
1803       /* unpack the address of the structure */
1804       CMCHKUNPK(oduUnpackPointer, (PTR *)&slotIndInfo, mBuf);
1805       ODU_PUT_MSG_BUF(mBuf);
1806       return (*func)(pst, slotIndInfo);
1807    }
1808
1809    ODU_PUT_MSG_BUF(mBuf);
1810    return RFAILED;
1811 }
1812
1813 /*******************************************************************
1814  *
1815  * @brief Pack and send Dl Pcch indication to MAC
1816  *
1817  * @details
1818  *
1819  *    Function : packDuMacDlPcchInd
1820  *
1821  *    Functionality:
1822  *       Pack and send Dl Pcch indication to MAC
1823  *
1824  * @params[in] Post structure
1825  *             MacPcchInd *pcchInd;
1826  * @return ROK     - success
1827  *         RFAILED - failure
1828  *
1829  * ****************************************************************/
1830
1831 uint8_t packDuMacDlPcchInd(Pst *pst, MacPcchInd *pcchInd)
1832 {
1833    Buffer *mBuf = NULLP;
1834
1835    if(pst->selector == ODU_SELECTOR_LWLC)
1836    {
1837       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
1838       {
1839          DU_LOG("\nERROR  --> MAC : packDuMacDlPcchInd(): Memory allocation failed ");
1840          return RFAILED;
1841       }
1842       CMCHKPK(oduPackPointer,(PTR)pcchInd, mBuf);
1843       return ODU_POST_TASK(pst,mBuf);
1844    }
1845    else
1846    {
1847       DU_LOG("\nERROR  -->  MAC: packDuMacDlPcchInd(): Only LWLC supported ");
1848    }
1849    return RFAILED;
1850 }
1851
1852 /*******************************************************************
1853  *
1854  * @brief Unpacks downlink pcch indication received from DU APP
1855  *
1856  * @details
1857  *
1858  *    Function : unpackMacDlPcchInd
1859  *
1860  *    Functionality:
1861  *         Unpacks downlink pcch indication received from DU APP
1862  *
1863  * @params[in] Pointer to Handler
1864  *             Post structure pointer
1865  *             Message Buffer
1866  * @return ROK     - success
1867  *         RFAILED - failure
1868  *
1869  * ****************************************************************/
1870
1871 uint8_t unpackMacDlPcchInd(DuMacDlPcchInd func, Pst *pst, Buffer *mBuf)
1872 {
1873    if(pst->selector == ODU_SELECTOR_LWLC)
1874    {
1875       MacPcchInd *pcchInd=NULLP;
1876
1877       /* unpack the address of the structure */
1878       CMCHKUNPK(oduUnpackPointer, (PTR *)&pcchInd, mBuf);
1879       ODU_PUT_MSG_BUF(mBuf);
1880       return (*func)(pst, pcchInd);
1881    }
1882    else
1883    {
1884       /* Nothing to do for other selectors */
1885       DU_LOG("\nERROR  -->  DU APP : unpackMacDlPcchInd(): Only LWLC supported");
1886       ODU_PUT_MSG_BUF(mBuf);
1887    }
1888
1889    return RFAILED;
1890 }
1891
1892 /*******************************************************************
1893  *
1894  * @brief Searches for first unset bit in ueBitMap
1895  *
1896  * @details
1897  *
1898  *    Function : getFreeBitFromUeBitMap
1899  *
1900  *    Functionality: Searches for first unset bit in ueBitMap of
1901  *       a cell. Search starts from LSB to MSB. Returns index of the
1902  *       free bit, considering LSB at index 0 and increasing index
1903  *       towards MSB.
1904  *
1905  * @params[in] Cell Id
1906  * @return Index of free bit - success 
1907  *         -1 - failure
1908  *
1909  * ****************************************************************/
1910 int8_t getFreeBitFromUeBitMap(uint16_t cellId)
1911 {
1912    uint8_t  bitIdx = 0;  /* bit position */
1913    uint16_t cellIdx = 0; /* Index to acces ueBitMapPerCell[] */
1914    uint64_t mask = 1;    /* bit mask */
1915
1916    GET_CELL_IDX(cellId, cellIdx);
1917    while(bitIdx < 64) 
1918    {   
1919       /* Find the first unset bit in Bit Map */
1920       if((ueBitMapPerCell[cellIdx] & (mask << bitIdx)) == 0)
1921       {   
1922          SET_ONE_BIT(bitIdx, ueBitMapPerCell[cellIdx]);
1923          return bitIdx;
1924       }   
1925       else
1926          bitIdx++;
1927    }   
1928    return -1; 
1929 }
1930
1931 /*******************************************************************
1932  *
1933  * @brief Unset a previously set bit in UeBitMap
1934  *
1935  * @details
1936  *
1937  *    Function : unsetBitInUeBitMap
1938  *
1939  *    Functionality: Searches for bit at given index and unset it.
1940  *
1941  * @params[in] Cell Id
1942  *             Bit Index
1943  * @return void 
1944  *
1945  * ****************************************************************/
1946 void unsetBitInUeBitMap(uint16_t cellId, uint8_t bitPos)
1947 {
1948     uint16_t cellIdx;
1949
1950    GET_CELL_IDX(cellId, cellIdx);
1951    UNSET_ONE_BIT(bitPos, ueBitMapPerCell[cellIdx]);
1952 }
1953
1954 /**********************************************************************
1955   End of file
1956  **********************************************************************/