1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /* This file contains message handling functionality for DU cell management */
25 #include "envopt.h" /* Environment options */
26 #include "envdep.h" /* Environment dependent */
27 #include "envind.h" /* Environment independent */
28 #include "gen.h" /* General */
29 #include "ssi.h" /* System services */
30 #include "cm5.h" /* Common timer defines */
31 #include "cm_tkns.h" /* Common tokens defines */
32 #include "cm_mblk.h" /* Common memory allocation library defines */
33 #include "cm_llist.h" /* Common link list defines */
34 #include "cm_hash.h" /* Common hashlist defines */
40 #include "du_app_mac_inf.h"
42 #include "gen.x" /* General */
43 #include "ssi.x" /* System services */
45 #include "cm5.x" /* Common timer library */
46 #include "cm_tkns.x" /* Common tokens */
47 #include "cm_mblk.x" /* Common memory allocation */
48 #include "cm_llist.x" /* Common link list */
49 #include "cm_hash.x" /* Common hashlist */
59 /* Memory related configs */
60 #define DU_APP_MEM_REGION 0
61 #define RLC_UL_MEM_REGION 1
62 #define RLC_DL_MEM_REGION 4
63 #define MAC_MEM_REGION 4
72 #define EVENT_CU_DATA 2
73 #define EVENT_SCTP_NTFY 3
74 #define EVTSRVOPENREQ 4
75 #define EVTSRVOPENCFM 5
76 #define EVTTNLMGMTREQ 6
77 #define EVTTNLMGMTCFM 7
79 #define EVTSTARTPOLL 9
80 #define EVENT_RIC_DATA 10
83 #define DU_SELECTOR_LC 0
84 #define DU_SELECTOR_TC 1
85 #define DU_SELECTOR_LWLC 2
96 #define DU_SAP_UNBOUND 1
97 #define DU_SAP_BINDING 2
98 #define DU_SAP_BOUND 3
100 #define DU_ZERO_VAL 0
102 #define DU_UE_START_CRNTI 100
108 #define RLC_GEN_CFG 1
109 #define RLC_MAC_SAP_CFG 2
110 #define RLC_UDX_SAP_CFG 4
112 #define MAC_GEN_CFG 1
113 #define MAC_SAP_CFG 2
114 #define MAX_MAC_SAP 2
116 #define DU_RLC_UL_CONFIGURED (RLC_GEN_CFG | \
117 RLC_MAC_SAP_CFG | RLC_UDX_SAP_CFG)
118 #define DU_RLC_DL_CONFIGURED DU_RLC_UL_CONFIGURED
120 #define MAC_CONFIGURED (MAC_GEN_CFG | MAC_SAP_CFG)
122 #define DU_SET_ZERO(_buf, _size) \
123 cmMemset((U8 *)(_buf), 0, _size);
125 /* allocate and zero out a static buffer */
126 #define DU_ALLOC(_datPtr, _size) \
129 _ret = SGetSBuf(DU_APP_MEM_REGION, DU_POOL, \
130 (Data **)&_datPtr, _size); \
132 cmMemset((U8*)_datPtr, 0, _size); \
137 /* free a static buffer */
138 #define DU_FREE(_datPtr, _size) \
140 SPutSBuf(DU_APP_MEM_REGION, DU_POOL, \
141 (Data *)_datPtr, _size);
143 /* Allocate shared memory to be used for LWLC
144 * during inter-layer communication */
145 #define DU_ALLOC_SHRABL_BUF(_buf, _size) \
147 if(SGetStaticBuffer(DU_APP_MEM_REGION, DU_POOL, \
148 (Data **)&_buf, (Size) _size, 0) == ROK) \
150 cmMemset((U8 *)(_buf), 0, _size); \
158 /* Free shared memory, received through LWLC */
159 #define DU_FREE_SHRABL_BUF(_region, _pool,_buf, _size) \
163 (Void) SPutStaticBuffer(_region, _pool, \
164 (Data *) _buf, (Size) _size, 0); \
173 ACTIVATION_IN_PROGRESS,
184 typedef struct cellCfgParams
186 NrEcgi nrEcgi; /* ECGI */
188 U16 fiveGsTac; /* 5gSTac */
189 Plmn plmn[MAX_PLMN]; /* List of serving PLMN IDs */
190 U32 maxUe; /* max UE per slot */
193 typedef struct duUeCb
195 uint32_t gnbDuUeF1apId; /* GNB DU UE F1AP ID */
196 uint32_t gnbCuUeF1apId; /* GNB CU UE F1AP ID */
201 typedef struct duCellCb
203 uint16_t cellId; /* Internal cell Id */
204 CellCfgParams cellInfo; /* Cell info */
205 Bool firstSlotIndRcvd;
206 CellStatus cellStatus; /* Cell status */
207 uint32_t numActvUes; /* Total Active UEs */
208 DuUeCb ueCb[DU_MAX_UE]; /* UE CONTEXT */
211 typedef struct duLSapCb
224 typedef struct ueCcchCtxt
226 uint32_t gnbDuUeF1apId; /* GNB DU UE F1AP ID */
227 uint16_t crnti; /* CRNTI */
228 uint16_t cellId; /* Cell Id */
235 Mem mem; /* Memory configs */
236 TskInit init; /* DU Init */
237 //DuLSapCb **macSap; /* MAC SAP */
238 Bool f1Status; /* Status of F1 connection */
239 Bool e2Status; /* Status of E2 connection */
240 DuCellCb* cfgCellLst[DU_MAX_CELLS]; /* List of cells at DU APP of type DuCellCb */
241 DuCellCb* actvCellLst[DU_MAX_CELLS]; /* List of cells activated/to be activated of type DuCellCb */
242 /* pointer to store the address of macCellCfg params used to send du-app to MAC */
243 MacCellCfg *duMacCellCfg; /* pointer to store params while sending DU-APP to MAC */
244 uint32_t numUe; /* current number of UEs */
245 UeCcchCtxt ueCcchCtxt[DU_MAX_UE]; /* mapping of gnbDuUeF1apId to CRNTI required for CCCH processing*/
249 typedef struct duLSapCfg
267 /* global variables */
269 //DuCfgParams duCfgParam;
271 /* DU Cell Functions */
272 S16 duActvInit(Ent entity, Inst inst, Region region, Reason reason);
273 S16 duActvTsk(Pst *pst, Buffer *mBuf);
274 S16 duSendRlcUlCfg();
275 S16 duSendRlcDlCfg();
276 S16 duBuildRlcCfg(Inst inst);
277 S16 duBuildRlcLsapCfg(Ent ent, Inst inst, U8 lsapInst);
278 S16 duBuildRlcUsapCfg(U8 elemId, Ent ent, Inst inst);
279 S16 duHdlRlcCfgComplete(Pst *pst, KwMngmt *cfm);
280 S16 duHdlRlcCntrlCfgComplete(Pst *pst, KwMngmt *cfm);
281 S16 duProcRlcUlCfgComplete(Pst *pst, KwMngmt *cfm);
282 S16 duProcRlcDlCfgComplete(Pst *pst, KwMngmt *cfm);
284 S16 duBuildMacGenCfg();
285 S16 duBuildMacUsapCfg(SpId sapId);
286 S16 duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm);
287 S16 duBindUnbindRlcToMacSap(U8 inst, U8 action);
288 S16 duProcCfgComplete();
290 S16 duSctpStartReq();
291 S16 duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy);
293 S16 duBuildEgtpCfgReq();
294 S16 duHdlEgtpCfgComplete(CmStatus cfm);
295 S16 duSendEgtpSrvOpenReq();
296 S16 duHdlEgtpSrvOpenComplete(CmStatus cfm);
297 S16 duSendEgtpTnlMgmtReq(U8 action, U32 lclTeid, U32 remTeid);
298 S16 duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm);
299 S16 duSendEgtpTestData();
300 S16 duSendEgtpDatInd(Buffer *mBuf);
301 S16 duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm);
302 uint16_t duBuildAndSendMacCellStartReq();
303 uint16_t duBuildAndSendMacCellStopReq();
307 /**********************************************************************
309 **********************************************************************/