MAC Clean-up [Issue-ID: ODUHIGH-212]
[o-du/l2.git] / src / du_app / du_mgr.h
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 /* This file contains message handling functionality for DU cell management */
20 #ifndef __DU_MGR_H__
21 #define __DU_MGR_H__
22 #define DU_PROC  0
23
24 /* Events */
25 #define EVTCFG 0
26 #define EVTSCTPSTRT  1
27 #define EVENT_CU_DATA  2
28 #define EVENT_SCTP_NTFY  3
29 #define EVTSRVOPENREQ  4
30 #define EVTSRVOPENCFM  5
31 #define EVTTNLMGMTREQ  6
32 #define EVTTNLMGMTCFM  7
33 #define EVTSLOTIND    8
34 #define EVTSTARTPOLL  9
35 #define EVENT_RIC_DATA  10
36
37
38 /* SAP IDs */
39 #define DU_MAC_SUID 0
40 #define DU_MAC_SPID 0
41
42 /* Instance */
43 #define RLC_UL_INST 0
44 #define RLC_DL_INST 1
45
46 /* SAP state */
47 #define DU_SAP_UNBOUND 1
48 #define DU_SAP_BINDING 2
49 #define DU_SAP_BOUND   3
50
51 #define DU_ZERO_VAL 0
52
53 /* Macros */
54 #define ADD 0
55 #define DEL 1
56
57 #define RLC_GEN_CFG      1
58 #define RLC_MAC_SAP_CFG  2
59 #define RLC_UDX_SAP_CFG  4
60
61 #define MAC_GEN_CFG   1
62 #define MAC_SAP_CFG   2
63 #define MAX_MAC_SAP   2
64
65 #define DU_RLC_UL_CONFIGURED  (RLC_GEN_CFG |  \
66       RLC_MAC_SAP_CFG | RLC_UDX_SAP_CFG)
67 #define DU_RLC_DL_CONFIGURED DU_RLC_UL_CONFIGURED
68
69 #define MAC_CONFIGURED (MAC_GEN_CFG | MAC_SAP_CFG)
70
71 #define DU_SET_ZERO(_buf, _size)   \
72    cmMemset((U8 *)(_buf), 0, _size);
73
74 typedef enum
75 {
76    CELL_OUT_OF_SERVICE,
77    ACTIVATION_IN_PROGRESS,
78    ACTIVATED,
79    DELETION_IN_PROGRESS
80 }CellStatus;
81
82 typedef enum
83 {
84    UE_INACTIVE,
85    UE_ACTIVE
86 }UeState;
87
88 typedef struct cellCfgParams
89 {
90    NrEcgi      nrEcgi;         /* ECGI */
91    U16         nrPci;          /* PCI */
92    U16         fiveGsTac;         /* 5gSTac */
93    Plmn      plmn[MAX_PLMN]; /* List of serving PLMN IDs */
94    U32         maxUe;          /* max UE per slot */
95 }CellCfgParams;
96
97 typedef struct duUeCb
98 {
99    uint32_t gnbDuUeF1apId; /* GNB DU UE F1AP ID */
100    uint32_t gnbCuUeF1apId; /* GNB CU UE F1AP ID */
101    UeState  ueState;
102    MacUeCfg macUeCfg;
103 }DuUeCb;
104
105 typedef struct duCellCb
106 {
107    uint16_t       cellId;           /* Internal cell Id */
108    CellCfgParams  cellInfo;         /* Cell info */
109    Bool           firstSlotIndRcvd;
110    CellStatus     cellStatus;       /* Cell status */
111    uint32_t       numActvUes;       /* Total Active UEs */
112    DuUeCb         ueCb[MAX_NUM_UE];  /* UE CONTEXT */
113 }DuCellCb;
114
115 typedef struct duLSapCb
116 {
117    Pst pst;
118    SuId        suId;
119    SpId        spId;
120    State       sapState;
121    Mem         mem;
122    CmTimer     timer;
123    U8          bndRetryCnt;
124    U8          maxBndRetry;
125    TmrCfg      bndTmr;
126 }DuLSapCb;
127
128 typedef struct ueCcchCtxt
129 {
130    uint32_t gnbDuUeF1apId; /* GNB DU UE F1AP ID */
131    uint16_t crnti;         /* CRNTI */
132    uint16_t cellId;        /* Cell Id */
133 }UeCcchCtxt;
134
135
136 /* DU APP DB */
137 typedef struct duCb
138 {
139    Mem           mem;    /* Memory configs */
140    TskInit       init;   /* DU Init */
141    //DuLSapCb      **macSap;  /* MAC SAP */
142    Bool          f1Status; /* Status of F1 connection */
143    Bool          e2Status; /* Status of E2 connection */
144    uint8_t       numCfgCells; 
145    DuCellCb*     cfgCellLst[MAX_NUM_CELL];     /* List of cells at DU APP of type DuCellCb */
146    uint8_t       numActvCells;
147    DuCellCb*     actvCellLst[MAX_NUM_CELL];    /* List of cells activated/to be activated of type DuCellCb */
148    /* pointer to store the address of macCellCfg params used to send du-app to MAC */
149    MacCellCfg    *duMacCellCfg;         /* pointer to store params while sending DU-APP to MAC */
150    uint32_t       numUe;            /* current number of UEs */
151    UeCcchCtxt     ueCcchCtxt[MAX_NUM_UE]; /* mapping of gnbDuUeF1apId to CRNTI required for CCCH processing*/
152 }DuCb;
153
154
155 typedef struct duLSapCfg
156 {
157    SuId        suId;
158    SpId        spId;
159    Ent         srcEnt;
160    Inst        srcInst;
161    ProcId      dstProcId;
162    Ent         dstEnt;
163    Inst        dstInst;
164    Priority    dstPrior;
165    Route       dstRoute;
166    Selector    dstSel;
167    Mem         mem;
168    U8          maxBndRetry;
169    TmrCfg      bndTmr;
170    TmrCfg      connTmr;
171 }DuLSapCfg;
172
173 /* global variables */
174 DuCb duCb;
175 //DuCfgParams duCfgParam;
176
177 /* DU Cell Functions */
178 S16 duActvInit(Ent entity, Inst inst, Region region, Reason reason);
179 S16 duActvTsk(Pst *pst, Buffer *mBuf);
180 S16 duSendRlcUlCfg();
181 S16 duSendRlcDlCfg();
182 S16 duBuildRlcCfg(Inst inst);
183 S16 duBuildRlcLsapCfg(Ent ent, Inst inst, U8 lsapInst);
184 S16 duBuildRlcUsapCfg(U8 elemId, Ent ent, Inst inst);
185 S16 duHdlRlcCfgComplete(Pst *pst, KwMngmt *cfm);
186 S16 duHdlRlcCntrlCfgComplete(Pst *pst, KwMngmt *cfm);
187 S16 duProcRlcUlCfgComplete(Pst *pst, KwMngmt *cfm);
188 S16 duProcRlcDlCfgComplete(Pst *pst, KwMngmt *cfm);
189 S16 duSendMacCfg();
190 S16 duBuildMacGenCfg();
191 S16 duBuildMacUsapCfg(SpId sapId);
192 S16 duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm);
193 S16 duBindUnbindRlcToMacSap(U8 inst, U8 action);
194 S16 duProcCfgComplete();
195 S16 duSendSchCfg();
196 S16 duSctpStartReq();
197 S16 duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy);
198
199 S16 duBuildEgtpCfgReq();
200 S16 duHdlEgtpCfgComplete(CmStatus cfm);
201 S16 duSendEgtpSrvOpenReq();
202 S16 duHdlEgtpSrvOpenComplete(CmStatus cfm);
203 S16 duSendEgtpTnlMgmtReq(U8 action, U32 lclTeid, U32 remTeid);
204 S16 duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm);
205 S16 duSendEgtpTestData();
206 S16 duSendEgtpDatInd(Buffer *mBuf);
207 S16 duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm);
208 uint8_t duBuildAndSendMacCellStartReq();
209 uint8_t duBuildAndSendMacCellStopReq();
210
211 #endif
212
213 /**********************************************************************
214   End of file
215  **********************************************************************/