[Epic-ID: ODUHIGH-488][Task-ID: ODUHIGH-501] Ue Create and Rsp correction in DUAPP...
[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 RlcDuUeCreateRsp rlcUeCreateRspOpts[] =
39 {
40    packRlcDuUeCreateRsp,     /* 0 - loosely coupled */
41    DuProcRlcUeCreateRsp,     /* 1 - tightly coupled */
42    packRlcDuUeCreateRsp     /* 2 - LWLC loosely coupled */
43 };
44
45 RlcDuUeReconfigRsp rlcUeReconfigRspOpts[] =
46 {
47    packRlcDuUeReconfigRsp,     /* 0 - loosely coupled */
48    DuProcRlcUeReconfigRsp,     /* 1 - tightly coupled */
49    packRlcDuUeReconfigRsp     /* 2 - LWLC loosely coupled */
50 };
51
52 /***********************************************************
53  *
54  * @brief  
55  *
56  *        Handler for the ue create response to DUAPP
57  *
58  * @b Description:
59  *
60  *        This function reports  ue create response to DUAPP
61  *
62  *  @param[in] post         Post structure  
63  *  @param[in] cfgRsp       ue create Config Response
64  *
65  *  @return  uint16_t
66  *      -# ROK 
67  *      -# RFAILED
68  *
69  *************************************************************/
70 uint8_t SendRlcUeCreateRspToDu(Pst *pst, RlcCfgCfmInfo *cfgRsp)
71 {
72    /* jump to specific primitive depending on configured selector */
73    uint8_t ret = ROK;
74    RlcCb   *gCb;
75    RlcUeCreateRsp *ueRsp = NULLP;
76
77    gCb = RLC_GET_RLCCB(pst->srcInst);
78    RLC_ALLOC_SHRABL_BUF(pst->region, pst->pool, ueRsp, sizeof(RlcUeCreateRsp));
79    if(!ueRsp)
80    {  
81       DU_LOG("\nERROR  -->  RLC: Memory allocation failed for ueRsp at SendRlcUeCreateRspToDu()");
82       ret = RFAILED;
83    }
84    else
85    {
86       /* Mapping Old api to New Api */
87       ret = fillRlcUeCreateRsp(ueRsp, cfgRsp);
88       if(!ret)
89       {
90          ret = (*rlcUeCreateRspOpts[pst->selector])(pst, ueRsp);
91          if(ret)
92          {
93             DU_LOG("\nERROR  -->  RLC: Failed at SendRlcUeCreateRspToDu()");
94             RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueRsp, sizeof(RlcUeCreateRsp));
95          }
96       }
97       else
98       {
99          DU_LOG("\nERROR  -->  RLC: Failed at fillRlcUeCreateRsp() for event %d", pst->event);
100          RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueRsp, sizeof(RlcUeCreateRsp));
101       }
102    }
103    RLC_FREE(gCb, cfgRsp, sizeof(RlcCfgCfmInfo));
104    return ret;
105 } /* end of SendRlcUeCreateRspToDu */
106
107 /***********************************************************
108  *
109  * @brief  
110  *
111  *        Handler for the ue Reconfig response to DUAPP
112  *
113  * @b Description:
114  *
115  *        This function reports  ue Reconfig response to DUAPP
116  *
117  *  @param[in] post         Post structure  
118  *  @param[in] cfgRsp       ue reconfig Config Response
119  *
120  *  @return  uint16_t
121  *      -# ROK 
122  *      -# RFAILED
123  *
124  *************************************************************/
125 uint8_t SendRlcUeReconfigRspToDu(Pst *pst, RlcCfgCfmInfo *cfgRsp)
126 {
127    /* jump to specific primitive depending on configured selector */
128    uint8_t ret = ROK;
129    RlcCb   *gCb;
130    RlcUeReconfigRsp *ueRsp = NULLP;
131
132    gCb = RLC_GET_RLCCB(pst->srcInst);
133    RLC_ALLOC_SHRABL_BUF(pst->region, pst->pool, ueRsp, sizeof(RlcUeReconfigRsp));
134    if(!ueRsp)
135    {  
136       DU_LOG("\nERROR  -->  RLC: Memory allocation failed for ueRsp at SendRlcUeReconfigRspToDu()");
137       ret = RFAILED;
138    }
139    else
140    {
141       /* Mapping Old api to New Api */
142       ret = fillRlcUeCreateRsp(ueRsp, cfgRsp);
143       if(!ret)
144       {
145          ret = (*rlcUeReconfigRspOpts[pst->selector])(pst, ueRsp);
146          if(ret)
147          {
148             DU_LOG("\nERROR  -->  RLC: Failed at SendRlcUeReconfigRspToDu()");
149             RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueRsp, sizeof(RlcUeReconfigRsp));
150          }
151       }
152       else
153       {
154          DU_LOG("\nERROR  -->  RLC: Failed at fillRlcUeCreateRsp() for event %d", pst->event);
155          RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueRsp, sizeof(RlcUeReconfigRsp));
156       }
157    }
158    RLC_FREE(gCb, cfgRsp, sizeof(RlcCfgCfmInfo));
159    return ret;
160 } /* end of SendRlcUeReconfigRspToDu */
161
162 /**********************************************************************
163          End of file
164 **********************************************************************/