60391efc0bc455a7225e3541403b0153c6d8e64a
[o-du/l2.git] / src / 5gnrrlc / rlc_mgr.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 /* This file defines API towards RLC interface */
19 #include "common_def.h"
20 #include "rgu.h"           /* RGU interface includes*/
21 #include "lkw.h"           /* LKW defines */
22 #include "ckw.h"           /* CKW defines */
23 #include "kwu.h"           /* KWU defines */
24 #include "rlc_env.h"        /* RLC environment options */
25 #include "rlc_err.h"
26
27
28 /* header/extern include files (.x) */
29 #include "rgu.x"           
30 #include "lkw.x"           /* LKW */
31 #include "ckw.x"           /* CKW */
32 #include "kwu.x"           /* KWU */
33
34 #include "rlc_utils.h"            /* RLC defines */
35 #include "du_app_rlc_inf.h"
36 #include "rlc_mgr.h"
37
38 RlcDuUeCfgRsp rlcUeCfgRspOpts[] =
39 {
40    packRlcDuUeCfgRsp,     /* 0 - loosely coupled */
41    DuProcRlcUeCfgRsp,     /* 1 - tightly coupled */
42    packRlcDuUeCfgRsp     /* 2 - LWLC loosely coupled */
43 };
44
45
46 /***********************************************************
47  *
48  * @brief  
49  *
50  *        Handler for the ue create response to DUAPP
51  *
52  * @b Description:
53  *
54  *        This function reports  ue create response to DUAPP
55  *
56  *  @param[in] post         Post structure  
57  *  @param[in] cfgRsp       ue create Config Response
58  *
59  *  @return  uint16_t
60  *      -# ROK 
61  *      -# RFAILED
62  *
63  *************************************************************/
64 uint8_t SendRlcUeCfgRspToDu(Pst *pst, RlcCfgCfmInfo *cfgRsp)
65 {
66    /* jump to specific primitive depending on configured selector */
67    uint8_t ret = ROK;
68    RlcCb   *gCb;
69    RlcUeCfgRsp *ueRsp = NULLP;
70
71    gCb = RLC_GET_RLCCB(pst->srcInst);
72    RLC_ALLOC_SHRABL_BUF(pst->region, pst->pool, ueRsp, sizeof(RlcUeCfgRsp));
73    if(!ueRsp)
74    {  
75       DU_LOG("\nERROR  -->  RLC: Memory allocation failed for ueRsp at SendRlcUeCreateRspToDu()");
76       ret = RFAILED;
77    }
78    else
79    {
80       /* Mapping Old api to New Api */
81       ret = fillRlcUeCfgRsp(ueRsp, cfgRsp);
82       if(!ret)
83       {
84          ret = (*rlcUeCfgRspOpts[pst->selector])(pst, ueRsp);
85          if(ret)
86          {
87             DU_LOG("\nERROR  -->  RLC: Failed at SendRlcUeCfgRspToDu()");
88             RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueRsp, sizeof(RlcUeCfgRsp));
89          }
90       }
91       else
92       {
93          DU_LOG("\nERROR  -->  RLC: Failed at fillRlcUeCfgRsp() for event %d", pst->event);
94          RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueRsp, sizeof(RlcUeCfgRsp));
95       }
96    }
97    RLC_FREE(gCb, cfgRsp, sizeof(RlcCfgCfmInfo));
98    return ret;
99 } /* end of SendRlcUeCfgRspToDu */
100
101 /**********************************************************************
102          End of file
103 **********************************************************************/