Stop Req and Stop Ind code changes
[o-du/l2.git] / src / cm / du_app_mac_inf.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 /* Defines APIs exchanged between du_app and cl module of MAC */
20 #ifndef __MACINT_H__
21 #define __MACINT_H__
22
23 #define NUM_NUMEROLOGY 5  /* Number of numerology */
24 #define MAXIMUM_TDD_PERIODICITY 5
25 #define MAX_SYMB_PER_SLOT 14 
26
27 #define NUM_SSB         1       /* max value is 64 */
28 #define SSB_MASK_SIZE   1       /* SSB mask size is 32bit for sub6 */
29 #define SIB1_NEW_TX_PERIOD      160
30 #define SIB1_REPETITION_PERIOD   20
31 #define CORESET_0_INDEX      0
32 #define SEARCHSPACE_0_INDEX   0
33 #define SEARCHSPACE_1_INDEX   1
34 #define SS_MONITORING_SLOT_SL1   0 /* all slots */
35 #define SS_MONITORING_SYMBOL     0x2000; /* symbol-0, set 14th bit */
36 #define SIB1_MCS  4
37
38 /* Macros for coupling */
39 #define DU_MAC_LC  0
40 #define DU_MAC_TC  1
41 #define DU_MAC_LWLC  2
42
43 /* Event IDs */
44 #define EVENT_MAC_CELL_CONFIG_REQ    200
45 #define EVENT_MAC_CELL_CONFIG_CFM    201
46 #define EVENT_MAC_CELL_START_REQ     202
47 #define EVENT_MAC_CELL_STOP_REQ      203
48 #define EVENT_MAC_SLOT_IND           204
49 #define EVENT_MAC_STOP_IND           205
50
51 typedef enum
52 {
53    DUP_MODE_FDD,
54    DUP_MODE_TDD
55 }DuplexMode;
56
57 typedef enum
58 {
59    MAC_GEN_FULL_PBCH_PAYLD,   /* MAC generated the full PBCH Payload */
60    PHY_GEN_TIMING_PBCH_BIT,   /* PHY generates the timing PBCH bits */
61    PHY_GEN_FULL_PBCH_PAYLD    /* PHY generates full PBCH payload */
62 }BchPduOpt;
63
64 typedef enum
65 {
66    LONG_SEQUENCE,
67    SHORT_SEQUENCE
68 }PrachSeqLen;
69
70 typedef enum
71 {
72    UNRESTRICTED,
73    RESTRICTED_SET_TYPE_A,
74    RESTRICTED_SET_TYPE_B
75 }RstSetCfg;
76
77 typedef enum
78 {
79    DONT_REPORT_RSSI,
80    RSSI_UNIT_DBM,
81    RSSI_UNIT_DBFS
82 }RSSIMeasUnit;
83
84 typedef enum
85 {
86    DL_SLOT,
87    UL_SLOT,
88    GUARD_SLOT
89 }SlotConfig;
90
91 typedef enum
92 {
93    TX_PRDCTY_MS_0P5,
94    TX_PRDCTY_MS_0P625,
95    TX_PRDCTY_MS_1,
96    TX_PRDCTY_MS_1P25,
97    TX_PRDCTY_MS_2,
98    TX_PRDCTY_MS_2P5,
99    TX_PRDCTY_MS_5,
100    TX_PRDCTY_MS_10
101 }DlUlTxPeriodicity;
102
103 typedef enum
104 {
105    BETA_PSS_0DB,
106    BETA_PSS_1DB
107 }BetaPss;
108
109 typedef enum 
110 {
111    SSB_PRDCTY_MS_5,
112    SSB_PRDCTY_MS_10,
113    SSB_PRDCTY_MS_20,
114    SSB_PRDCTY_MS_40,
115    SSB_PRDCTY_MS_80,
116    SSB_PRDCTY_MS_160
117 }SSBPeriod;
118
119 typedef struct carrierCfg
120 {
121    Bool  pres;
122    U16   bw;             /* DL/UL bandwidth */
123    U32   freq;           /* Absolute frequency of DL/UL point A in KHz */
124    U16   k0[NUM_NUMEROLOGY];          /* K0 for DL/UL */
125    U16   gridSize[NUM_NUMEROLOGY];    /* DL/UL Grid size for each numerologies */
126    U16   numAnt;         /* Number of Tx/Rx antennas */
127 }CarrierCfg;
128
129 typedef struct ssbCfg
130 {
131    uint32_t    ssbPbchPwr;       /* SSB block power */
132    BchPduOpt   bchPayloadFlag;   /* Options for generation of payload */
133    uint8_t     scsCmn;           /* subcarrier spacing for common */
134    uint16_t    ssbOffsetPointA;  /* SSB subcarrier offset from point A */
135    BetaPss     betaPss;
136    SSBPeriod   ssbPeriod;        /* SSB Periodicity in msec */
137    uint8_t     ssbScOffset;       /* Subcarrier Offset */
138    uint8_t     mibPdu[3];           /* MIB payload */
139    uint32_t    ssbMask[SSB_MASK_SIZE];      /* Bitmap for actually transmitted SSB. */
140    uint8_t     beamId[NUM_SSB];
141    Bool        multCarrBand;     /* Multiple carriers in a band */
142    Bool        multCellCarr;     /* Multiple cells in single carrier */
143 }SsbCfg;
144
145 typedef struct fdmInfo
146 {
147    U16   rootSeqIdx;        /* Root sequence index */
148    U8    numRootSeq;        /* Number of root sequences required for FD */
149    U16   k1;                /* Frequency Offset for each FD */
150    U8    zeroCorrZoneCfg;   /* Zero correlation zone cofig */
151    U8    numUnusedRootSeq;  /* Number of unused root sequence */
152    U8    *unsuedRootSeq;     /* Unused root sequence per FD */
153 }PrachFdmInfo;
154
155 typedef struct prachCfg
156 {
157    Bool          pres;
158         uint8_t       prachCfgIdx;         /* PRACH Cfg Index */
159    PrachSeqLen   prachSeqLen;         /* RACH Sequence length: Long/short */
160    uint8_t       prachSubcSpacing;    /* Subcarrier spacing of RACH */
161    RstSetCfg     prachRstSetCfg;      /* PRACH restricted set config */
162         uint16_t      msg1FreqStart;       /* Msg1-FrequencyStart */
163    uint8_t       msg1Fdm;             /* PRACH FDM (1,2,4,8) */
164    PrachFdmInfo  fdm[8];              /* FDM info */
165    uint8_t       ssbPerRach;          /* SSB per RACH occassion */
166    Bool          prachMultCarrBand;   /* Multiple carriers in Band */
167    uint8_t       prachRestrictedSet; /* Support for PRACH restricted set */
168         uint8_t       raContResTmr;        /* RA Contention Resoultion Timer */
169         uint8_t       rsrpThreshSsb;       /* RSRP Threshold SSB */
170    uint8_t       raRspWindow;         /* RA Response Window */
171 }PrachCfg;
172
173 typedef struct tddCfg
174 {
175    Bool               pres;
176    DlUlTxPeriodicity  tddPeriod;      /* DL UL Transmission periodicity */
177    SlotConfig         slotCfg[MAXIMUM_TDD_PERIODICITY][MAX_SYMB_PER_SLOT]; 
178 }TDDCfg;
179
180 typedef struct sib1CellCfg
181 {
182    uint8_t  *sib1Pdu;
183    uint16_t sib1PduLen;
184    uint16_t sib1NewTxPeriod;
185    uint16_t sib1RepetitionPeriod;
186    uint8_t coresetZeroIndex;     /* derived from 4 LSB of pdcchSib1 present in MIB */
187    uint8_t searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */
188    uint16_t sib1Mcs;
189 } Sib1CellCfg; 
190
191 typedef struct bwpParams
192 {
193    uint16_t firstPrb;
194    uint16_t numPrb;
195         uint8_t  scs;
196         uint8_t  cyclicPrefix;
197 }BwpParams;
198
199 typedef struct candidatesInfo
200 {
201    uint8_t aggLevel1;
202    uint8_t aggLevel2;
203    uint8_t aggLevel4;
204    uint8_t aggLevel8;
205    uint8_t aggLevel16;
206 }CandidatesInfo;
207
208 typedef struct searchSpaceCfg
209 {
210    uint8_t searchSpaceId;
211         uint8_t coresetId;
212         uint16_t monitoringSlot;
213         uint16_t duration;
214         uint16_t monitoringSymbol;
215         CandidatesInfo candidate;
216 }SearchSpaceCfg;
217
218 typedef struct pdcchConfigCommon
219 {
220    SearchSpaceCfg raSearchSpace;
221 }PdcchConfigCommon;
222
223 typedef struct bwpDlConfig
224 {
225    BwpParams      bwp;
226         PdcchConfigCommon pdcchCommon;
227 }BwpDlConfig;
228
229 typedef struct macCellCfg
230 {
231    U16            transId;
232    U16            cellId;     /* Cell Id */
233    U8             numTlv;     /* Number of configuration TLVs */
234    U8             carrierId;  /* Carrired Index */
235    U16            phyCellId;  /* Physical cell id */
236    DuplexMode     dupType;    /* Duplex type: TDD/FDD */
237    CarrierCfg     dlCarrCfg;  /* DL Carrier configuration */
238    CarrierCfg     ulCarrCfg;  /* UL Carrier configuration */
239    Bool           freqShft;   /* Indicates presence of 7.5kHz frequency shift */
240    SsbCfg         ssbCfg;     /* SSB configuration */          
241    PrachCfg       prachCfg;   /* PRACH Configuration */
242    TDDCfg         tddCfg;     /* TDD periodicity and slot configuration */
243    RSSIMeasUnit   rssiUnit;   /* RSSI measurement unit */
244    Sib1CellCfg    sib1Cfg;
245         BwpDlConfig    initialBwp;
246 }MacCellCfg;
247
248 typedef struct macCellCfgCfm
249 {
250         uint8_t        rsp; 
251    U16            transId;
252 }MacCellCfgCfm;
253
254 typedef struct slotInfo
255 {
256    uint16_t cellId;
257    uint16_t sfn;
258    uint16_t slot;
259 }SlotInfo;
260
261 typedef struct macCellStartInfo
262 {
263    uint16_t cellId;
264 }MacCellStartInfo;
265
266 typedef struct macCellStopInfo
267 {
268    uint16_t cellId;
269 }MacCellStopInfo;
270
271 /* Functions for slot Ind from MAC to DU APP*/
272 typedef uint16_t (*DuMacSlotInd) ARGS((
273    Pst       *pst,
274    SlotInfo  *slotInfo ));
275
276 extern uint16_t packMacSlotInd(Pst *pst, SlotInfo *slotInfo );
277 extern uint16_t unpackMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf);
278 extern uint16_t duHandleSlotInd(Pst *pst, SlotInfo *slotInfo);
279
280 /* Functions for stop Ind from MAC to DU APP*/
281 typedef uint16_t (*DuMacStopInd) ARGS((
282    Pst       *pst,
283    MacCellStopInfo  *cellId ));
284
285 extern uint16_t packMacStopInd(Pst *pst, MacCellStopInfo *cellId);
286 extern uint16_t unpackMacStopInd(DuMacStopInd func, Pst *pst, Buffer *mBuf);
287 extern uint16_t duHandleStopInd(Pst *pst, MacCellStopInfo *cellId);
288
289 /* Functions for mac cell start req */
290 typedef uint16_t (*DuMacCellStartReq) ARGS((
291    Pst               *pst, 
292    MacCellStartInfo  *cellStartInfo ));
293
294 extern uint16_t packMacCellStartReq(Pst *pst, MacCellStartInfo  *cellStartInfo);
295 extern uint16_t unpackMacCellStartReq(DuMacCellStartReq func, Pst *pst, Buffer *mBuf);
296 extern uint16_t MacHdlCellStartReq(Pst *pst, MacCellStartInfo  *cellStartInfo);
297
298 /* Functions for mac cell stop request */
299 typedef uint16_t (*DuMacCellStopReq) ARGS((
300    Pst               *pst,
301    MacCellStopInfo  *cellStopInfo ));
302  
303 extern uint16_t packMacCellStopReq(Pst *pst, MacCellStopInfo  *cellStopInfo);
304 extern uint16_t unpackMacCellStopReq(DuMacCellStopReq func, Pst *pst, Buffer *mBuf);
305 extern uint16_t MacHdlCellStopReq(Pst *pst, MacCellStopInfo  *cellStopInfo);
306
307 /* Function pointers for packing macCellCfg Request and Confirm */
308 typedef int (*packMacCellCfgReq) ARGS((
309    Pst           *pst,
310    MacCellCfg    *macCellCfg ));
311
312 typedef int (*packMacCellCfgConfirm) ARGS((
313    Pst              *pst,
314    MacCellCfgCfm    *macCellCfgCfm ));
315
316 typedef int (*DuMacCellCfgReq) ARGS((
317    Pst        *pst,        
318    MacCellCfg *macCellCfg));
319
320 typedef int (*DuMacCellCfgCfm) ARGS((
321    Pst        *pst,        
322    MacCellCfgCfm *macCellCfgCfm ));
323
324 extern int  packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg);
325 extern int MacHdlCellCfgReq(Pst *pst, MacCellCfg *macCellCfg);
326 extern void cmUnpackLwLcMacCellCfg(DuMacCellCfgReq func, Pst *pst, Buffer *mBuf);
327 extern int unpackMacCellCfgCfm(DuMacCellCfgCfm func, Pst *pst, Buffer *mBuf);
328 extern int duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm);
329 uint8_t sendStopIndMacToDuApp();
330 #endif
331
332 /**********************************************************************
333          End of file
334 **********************************************************************/