MAC/SCH Ue Delete Request and Response [JIRA ID - ODUHIGH-318]
[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;
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  * @brief Unpacks UE Reconfig Request received from DU APP
869  *
870  * @details
871  *
872  *    Function : unpackMacUeReconfigReq
873  *
874  *    Functionality:
875  *         Unpacks UE Reconfig Request received from DU APP
876  *
877  * @params[in] Pointer to Handler
878  *             Post structure pointer
879  *             Message Buffer
880  * @return ROK     - success
881  *         RFAILED - failure
882  *
883  * ****************************************************************/
884 uint8_t unpackMacUeReconfigReq(DuMacUeReconfigReq func, Pst *pst, Buffer *mBuf)
885 {
886    if(pst->selector == ODU_SELECTOR_LWLC)
887    {
888       MacUeCfg *ueCfg;
889
890       /* unpack the address of the structure */
891       CMCHKUNPK(oduUnpackPointer, (PTR *)&ueCfg, mBuf);
892       ODU_PUT_MSG_BUF(mBuf);
893       return (*func)(pst, ueCfg);
894    }
895    else
896    {
897       /* Nothing to do for other selectors */
898       DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for UE Create Request ");
899       ODU_PUT_MSG_BUF(mBuf);
900    }
901
902    return RFAILED;
903 }
904 /*******************************************************************
905 *
906 * @brief Packs and Sends UE Delete Request from DUAPP to MAC
907 *
908 * @details
909 *
910 *    Function : packDuMacUeDeleteReq
911 *
912 *    Functionality:
913 *       Packs and Sends UE Delete Request from DUAPP to MAC
914 *
915 *
916 * @params[in] Post structure pointer
917 *             MacUeDelete pointer
918 * @return ROK     - success
919 *         RFAILED - failure
920 *
921 * ****************************************************************/
922 uint8_t packDuMacUeDeleteReq(Pst *pst, MacUeDelete *ueDel)
923 {
924     Buffer *mBuf = NULLP;
925
926     if(pst->selector == ODU_SELECTOR_LWLC)
927     {
928        if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
929        {
930           DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacUeDeleteReq");
931           return RFAILED;
932        }
933        /* pack the address of the structure */
934        CMCHKPK(oduPackPointer,(PTR)ueDel, mBuf);
935     }
936     else
937     {
938        DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacUeDeleteReq");
939        return RFAILED;
940     }
941
942     return ODU_POST_TASK(pst,mBuf);
943 }
944 /*******************************************************************
945 *
946 * @brief Unpacks UE Delete Request received from DU APP
947 *
948 * @details
949 *
950 *    Function : unpackMacUeDeleteReq 
951 *
952 *    Functionality:
953 *         Unpacks UE Delete Request received from DU APP
954 *
955 * @params[in] Pointer to Handler
956 *             Post structure pointer
957 *             Message Buffer
958 * @return ROK     - success
959 *         RFAILED - failure
960 *
961 * ****************************************************************/
962 uint8_t unpackMacUeDeleteReq(DuMacUeDeleteReq func, Pst *pst, Buffer *mBuf)
963 {
964     if(pst->selector == ODU_SELECTOR_LWLC)
965     {
966        MacUeDelete *ueDelete;
967
968        /* unpack the address of the structure */
969        CMCHKUNPK(oduUnpackPointer, (PTR *)&ueDelete, mBuf);
970        ODU_PUT_MSG_BUF(mBuf);
971        return (*func)(pst, ueDelete);
972     }
973     else
974     {
975        /* Nothing to do for other selectors */
976        DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for UE Delete Request ");
977        ODU_PUT_MSG_BUF(mBuf);
978     }
979
980     return RFAILED;
981 }
982 /*******************************************************************
983  *
984  * @brief Pack and send UE delete response from MAC to DU APP
985  *
986  * @details
987  *
988  *    Function : packDuMacUeDeleteRsp
989  *
990  *    Functionality:
991  *       Pack and send UE  delete response from MAC to DU APP
992  *
993  * @params[in]
994  * @return ROK     - success
995  *         RFAILED - failure
996  *
997  * ****************************************************************/
998 uint8_t packDuMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
999 {
1000    Buffer *mBuf = NULLP;
1001    
1002    if(pst->selector == ODU_SELECTOR_LWLC)
1003    {
1004       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
1005       {
1006          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacUeDeleteRsp");
1007          return RFAILED;
1008       }
1009       /* pack the address of the structure */
1010       CMCHKPK(oduPackPointer,(PTR)deleteRsp, mBuf);
1011    }
1012    else
1013    {
1014       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacUeDeleteRsp");
1015       return RFAILED;
1016    }
1017    
1018    return ODU_POST_TASK(pst,mBuf);
1019    
1020 }
1021
1022 /*******************************************************************
1023 *
1024 * @brief Unpack UE Config Response from MAC to DU APP
1025 *
1026 * @details
1027 *
1028 *    Function :unpackDuMacUeDeleteRsp 
1029 *
1030 *    Functionality: Unpack UE Config Response from MAC to DU APP
1031 *
1032 * @params[in]
1033 * @return ROK     - success
1034 *         RFAILED - failure
1035 *
1036 * ****************************************************************/
1037 uint8_t unpackDuMacUeDeleteRsp(MacDuUeDeleteRspFunc func, Pst *pst, Buffer *mBuf)
1038 {
1039     if(pst->selector == ODU_SELECTOR_LWLC)
1040     {
1041        MacUeDeleteRsp *ueDeleteRsp = NULLP;
1042
1043        /* unpack the address of the structure */
1044        CMCHKUNPK(oduUnpackPointer, (PTR *)&ueDeleteRsp, mBuf);
1045        ODU_PUT_MSG_BUF(mBuf);
1046        return (*func)(pst, ueDeleteRsp);
1047     }
1048
1049     ODU_PUT_MSG_BUF(mBuf);
1050     return RFAILED;
1051 }
1052
1053 /**********************************************************************
1054 End of file
1055 **********************************************************************/