Changes for msg3 resource allocation
[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 pdschConfigCommon
224 {
225    uint8_t k0;
226         uint8_t mappingType;
227         uint8_t startSymbol;
228         uint8_t lengthSymbol;
229 }PdschConfigCommon;
230
231 typedef struct puschConfigCommon
232 {
233    /* PUSCH-TimeDomainResourceAllocation info */
234    uint8_t k2;
235         uint8_t mappingType;
236         uint8_t startSymbol;
237         uint8_t lengthSymbol;
238 }PuschConfigCommon;
239
240 typedef struct bwpDlConfig
241 {
242    BwpParams      bwp;
243         PdcchConfigCommon pdcchCommon;
244         PdschConfigCommon pdschCommon;
245 }BwpDlConfig;
246
247 typedef struct bwpUlConfig
248 {
249    BwpParams      bwp;
250         // rach config common sent in PrachCfg
251         // pucch info not required
252         PuschConfigCommon puschCommon;
253 }BwpUlConfig;
254
255 typedef struct macCellCfg
256 {
257    U16            transId;
258    U16            cellId;     /* Cell Id */
259    U8             numTlv;     /* Number of configuration TLVs */
260    U8             carrierId;  /* Carrired Index */
261    U16            phyCellId;  /* Physical cell id */
262    DuplexMode     dupType;    /* Duplex type: TDD/FDD */
263    CarrierCfg     dlCarrCfg;  /* DL Carrier configuration */
264    CarrierCfg     ulCarrCfg;  /* UL Carrier configuration */
265    Bool           freqShft;   /* Indicates presence of 7.5kHz frequency shift */
266    SsbCfg         ssbCfg;     /* SSB configuration */          
267    PrachCfg       prachCfg;   /* PRACH Configuration */
268    TDDCfg         tddCfg;     /* TDD periodicity and slot configuration */
269    RSSIMeasUnit   rssiUnit;   /* RSSI measurement unit */
270    Sib1CellCfg    sib1Cfg;
271         BwpDlConfig    initialDlBwp;
272         BwpUlConfig    initialUlBwp;
273 }MacCellCfg;
274
275 typedef struct macCellCfgCfm
276 {
277         uint8_t        rsp; 
278    U16            transId;
279 }MacCellCfgCfm;
280
281 typedef struct slotInfo
282 {
283    uint16_t cellId;
284    uint16_t sfn;
285    uint16_t slot;
286 }SlotInfo;
287
288 typedef struct macCellStartInfo
289 {
290    uint16_t cellId;
291 }MacCellStartInfo;
292
293 typedef struct macCellStopInfo
294 {
295    uint16_t cellId;
296 }MacCellStopInfo;
297
298 /* Functions for slot Ind from MAC to DU APP*/
299 typedef uint16_t (*DuMacSlotInd) ARGS((
300    Pst       *pst,
301    SlotInfo  *slotInfo ));
302
303 extern uint16_t packMacSlotInd(Pst *pst, SlotInfo *slotInfo );
304 extern uint16_t unpackMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf);
305 extern uint16_t duHandleSlotInd(Pst *pst, SlotInfo *slotInfo);
306
307 /* Functions for stop Ind from MAC to DU APP*/
308 typedef uint16_t (*DuMacStopInd) ARGS((
309    Pst       *pst,
310    MacCellStopInfo  *cellId ));
311
312 extern uint16_t packMacStopInd(Pst *pst, MacCellStopInfo *cellId);
313 extern uint16_t unpackMacStopInd(DuMacStopInd func, Pst *pst, Buffer *mBuf);
314 extern uint16_t duHandleStopInd(Pst *pst, MacCellStopInfo *cellId);
315
316 /* Functions for mac cell start req */
317 typedef uint16_t (*DuMacCellStartReq) ARGS((
318    Pst               *pst, 
319    MacCellStartInfo  *cellStartInfo ));
320
321 extern uint16_t packMacCellStartReq(Pst *pst, MacCellStartInfo  *cellStartInfo);
322 extern uint16_t unpackMacCellStartReq(DuMacCellStartReq func, Pst *pst, Buffer *mBuf);
323 extern uint16_t MacHdlCellStartReq(Pst *pst, MacCellStartInfo  *cellStartInfo);
324
325 /* Functions for mac cell stop request */
326 typedef uint16_t (*DuMacCellStopReq) ARGS((
327    Pst               *pst,
328    MacCellStopInfo  *cellStopInfo ));
329  
330 extern uint16_t packMacCellStopReq(Pst *pst, MacCellStopInfo  *cellStopInfo);
331 extern uint16_t unpackMacCellStopReq(DuMacCellStopReq func, Pst *pst, Buffer *mBuf);
332 extern uint16_t MacHdlCellStopReq(Pst *pst, MacCellStopInfo  *cellStopInfo);
333
334 /* Function pointers for packing macCellCfg Request and Confirm */
335 typedef int (*packMacCellCfgReq) ARGS((
336    Pst           *pst,
337    MacCellCfg    *macCellCfg ));
338
339 typedef int (*packMacCellCfgConfirm) ARGS((
340    Pst              *pst,
341    MacCellCfgCfm    *macCellCfgCfm ));
342
343 typedef int (*DuMacCellCfgReq) ARGS((
344    Pst        *pst,        
345    MacCellCfg *macCellCfg));
346
347 typedef int (*DuMacCellCfgCfm) ARGS((
348    Pst        *pst,        
349    MacCellCfgCfm *macCellCfgCfm ));
350
351 extern int  packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg);
352 extern int MacHdlCellCfgReq(Pst *pst, MacCellCfg *macCellCfg);
353 extern void cmUnpackLwLcMacCellCfg(DuMacCellCfgReq func, Pst *pst, Buffer *mBuf);
354 extern int unpackMacCellCfgCfm(DuMacCellCfgCfm func, Pst *pst, Buffer *mBuf);
355 extern int duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm);
356 uint8_t sendStopIndMacToDuApp();
357 #endif
358
359 /**********************************************************************
360          End of file
361 **********************************************************************/