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