msg3 and msg4 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 #define EVENT_MAC_UL_CCCH_IND        206
51 #define EVENT_MAC_DL_CCCH_IND        207
52
53 typedef enum
54 {
55    DUP_MODE_FDD,
56    DUP_MODE_TDD
57 }DuplexMode;
58
59 typedef enum
60 {
61    MAC_GEN_FULL_PBCH_PAYLD,   /* MAC generated the full PBCH Payload */
62    PHY_GEN_TIMING_PBCH_BIT,   /* PHY generates the timing PBCH bits */
63    PHY_GEN_FULL_PBCH_PAYLD    /* PHY generates full PBCH payload */
64 }BchPduOpt;
65
66 typedef enum
67 {
68    LONG_SEQUENCE,
69    SHORT_SEQUENCE
70 }PrachSeqLen;
71
72 typedef enum
73 {
74    UNRESTRICTED,
75    RESTRICTED_SET_TYPE_A,
76    RESTRICTED_SET_TYPE_B
77 }RstSetCfg;
78
79 typedef enum
80 {
81    DONT_REPORT_RSSI,
82    RSSI_UNIT_DBM,
83    RSSI_UNIT_DBFS
84 }RSSIMeasUnit;
85
86 typedef enum
87 {
88    DL_SLOT,
89    UL_SLOT,
90    GUARD_SLOT
91 }SlotConfig;
92
93 typedef enum
94 {
95    TX_PRDCTY_MS_0P5,
96    TX_PRDCTY_MS_0P625,
97    TX_PRDCTY_MS_1,
98    TX_PRDCTY_MS_1P25,
99    TX_PRDCTY_MS_2,
100    TX_PRDCTY_MS_2P5,
101    TX_PRDCTY_MS_5,
102    TX_PRDCTY_MS_10
103 }DlUlTxPeriodicity;
104
105 typedef enum
106 {
107    BETA_PSS_0DB,
108    BETA_PSS_1DB
109 }BetaPss;
110
111 typedef enum 
112 {
113    SSB_PRDCTY_MS_5,
114    SSB_PRDCTY_MS_10,
115    SSB_PRDCTY_MS_20,
116    SSB_PRDCTY_MS_40,
117    SSB_PRDCTY_MS_80,
118    SSB_PRDCTY_MS_160
119 }SSBPeriod;
120
121 typedef enum
122 {
123    RRC_REJECT,
124    RRC_SETUP
125 }DlCcchMsgType;
126
127 typedef struct carrierCfg
128 {
129    Bool  pres;
130    U16   bw;             /* DL/UL bandwidth */
131    U32   freq;           /* Absolute frequency of DL/UL point A in KHz */
132    U16   k0[NUM_NUMEROLOGY];          /* K0 for DL/UL */
133    U16   gridSize[NUM_NUMEROLOGY];    /* DL/UL Grid size for each numerologies */
134    U16   numAnt;         /* Number of Tx/Rx antennas */
135 }CarrierCfg;
136
137 typedef struct ssbCfg
138 {
139    uint32_t    ssbPbchPwr;       /* SSB block power */
140    BchPduOpt   bchPayloadFlag;   /* Options for generation of payload */
141    uint8_t     scsCmn;           /* subcarrier spacing for common */
142    uint16_t    ssbOffsetPointA;  /* SSB subcarrier offset from point A */
143    BetaPss     betaPss;
144    SSBPeriod   ssbPeriod;        /* SSB Periodicity in msec */
145    uint8_t     ssbScOffset;       /* Subcarrier Offset */
146    uint8_t     mibPdu[3];           /* MIB payload */
147    uint32_t    ssbMask[SSB_MASK_SIZE];      /* Bitmap for actually transmitted SSB. */
148    uint8_t     beamId[NUM_SSB];
149    Bool        multCarrBand;     /* Multiple carriers in a band */
150    Bool        multCellCarr;     /* Multiple cells in single carrier */
151 }SsbCfg;
152
153 typedef struct fdmInfo
154 {
155    U16   rootSeqIdx;        /* Root sequence index */
156    U8    numRootSeq;        /* Number of root sequences required for FD */
157    U16   k1;                /* Frequency Offset for each FD */
158    U8    zeroCorrZoneCfg;   /* Zero correlation zone cofig */
159    U8    numUnusedRootSeq;  /* Number of unused root sequence */
160    U8    *unsuedRootSeq;     /* Unused root sequence per FD */
161 }PrachFdmInfo;
162
163 typedef struct prachCfg
164 {
165    Bool          pres;
166         uint8_t       prachCfgIdx;         /* PRACH Cfg Index */
167    PrachSeqLen   prachSeqLen;         /* RACH Sequence length: Long/short */
168    uint8_t       prachSubcSpacing;    /* Subcarrier spacing of RACH */
169    RstSetCfg     prachRstSetCfg;      /* PRACH restricted set config */
170         uint16_t      msg1FreqStart;       /* Msg1-FrequencyStart */
171    uint8_t       msg1Fdm;             /* PRACH FDM (1,2,4,8) */
172    PrachFdmInfo  fdm[8];              /* FDM info */
173    uint8_t       ssbPerRach;          /* SSB per RACH occassion */
174    Bool          prachMultCarrBand;   /* Multiple carriers in Band */
175    uint8_t       prachRestrictedSet; /* Support for PRACH restricted set */
176         uint8_t       raContResTmr;        /* RA Contention Resoultion Timer */
177         uint8_t       rsrpThreshSsb;       /* RSRP Threshold SSB */
178    uint8_t       raRspWindow;         /* RA Response Window */
179 }PrachCfg;
180
181 typedef struct tddCfg
182 {
183    Bool               pres;
184    DlUlTxPeriodicity  tddPeriod;      /* DL UL Transmission periodicity */
185    SlotConfig         slotCfg[MAXIMUM_TDD_PERIODICITY][MAX_SYMB_PER_SLOT]; 
186 }TDDCfg;
187
188 typedef struct sib1CellCfg
189 {
190    uint8_t  *sib1Pdu;
191    uint16_t sib1PduLen;
192    uint16_t sib1NewTxPeriod;
193    uint16_t sib1RepetitionPeriod;
194    uint8_t coresetZeroIndex;     /* derived from 4 LSB of pdcchSib1 present in MIB */
195    uint8_t searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */
196    uint16_t sib1Mcs;
197 } Sib1CellCfg; 
198
199 typedef struct bwpParams
200 {
201    uint16_t firstPrb;
202    uint16_t numPrb;
203         uint8_t  scs;
204         uint8_t  cyclicPrefix;
205 }BwpParams;
206
207 typedef struct candidatesInfo
208 {
209    uint8_t aggLevel1;
210    uint8_t aggLevel2;
211    uint8_t aggLevel4;
212    uint8_t aggLevel8;
213    uint8_t aggLevel16;
214 }CandidatesInfo;
215
216 typedef struct searchSpaceCfg
217 {
218    uint8_t searchSpaceId;
219         uint8_t coresetId;
220         uint16_t monitoringSlot;
221         uint16_t duration;
222         uint16_t monitoringSymbol;
223         CandidatesInfo candidate;
224 }SearchSpaceCfg;
225
226 typedef struct pdcchConfigCommon
227 {
228    SearchSpaceCfg raSearchSpace;
229 }PdcchConfigCommon;
230
231 typedef struct pdschConfigCommon
232 {
233    uint8_t k0;
234         uint8_t mappingType;
235         uint8_t startSymbol;
236         uint8_t lengthSymbol;
237 }PdschConfigCommon;
238
239 typedef struct puschConfigCommon
240 {
241    /* PUSCH-TimeDomainResourceAllocation info */
242    uint8_t k2;
243         uint8_t mappingType;
244         uint8_t startSymbol;
245         uint8_t lengthSymbol;
246 }PuschConfigCommon;
247
248 typedef struct bwpDlConfig
249 {
250    BwpParams      bwp;
251         PdcchConfigCommon pdcchCommon;
252         PdschConfigCommon pdschCommon;
253 }BwpDlConfig;
254
255 typedef struct bwpUlConfig
256 {
257    BwpParams      bwp;
258         // rach config common sent in PrachCfg
259         // pucch info not required
260         PuschConfigCommon puschCommon;
261 }BwpUlConfig;
262
263 typedef struct macCellCfg
264 {
265    U16            transId;
266    U16            cellId;     /* Cell Id */
267    U8             numTlv;     /* Number of configuration TLVs */
268    U8             carrierId;  /* Carrired Index */
269    U16            phyCellId;  /* Physical cell id */
270    DuplexMode     dupType;    /* Duplex type: TDD/FDD */
271    CarrierCfg     dlCarrCfg;  /* DL Carrier configuration */
272    CarrierCfg     ulCarrCfg;  /* UL Carrier configuration */
273    Bool           freqShft;   /* Indicates presence of 7.5kHz frequency shift */
274    SsbCfg         ssbCfg;     /* SSB configuration */          
275    PrachCfg       prachCfg;   /* PRACH Configuration */
276    TDDCfg         tddCfg;     /* TDD periodicity and slot configuration */
277    RSSIMeasUnit   rssiUnit;   /* RSSI measurement unit */
278    Sib1CellCfg    sib1Cfg;
279         BwpDlConfig    initialDlBwp;
280         BwpUlConfig    initialUlBwp;
281 }MacCellCfg;
282
283 typedef struct macCellCfgCfm
284 {
285         uint8_t        rsp; 
286    U16            transId;
287 }MacCellCfgCfm;
288
289 typedef struct slotInfo
290 {
291    uint16_t cellId;
292    uint16_t sfn;
293    uint16_t slot;
294 }SlotInfo;
295
296 typedef struct macCellStartInfo
297 {
298    uint16_t cellId;
299 }MacCellStartInfo;
300
301 typedef struct macCellStopInfo
302 {
303    uint16_t cellId;
304 }MacCellStopInfo;
305
306 typedef struct ulCcchInd
307 {
308    uint16_t cellId;
309    uint16_t crnti;
310    uint8_t  *ulCcchMsg;
311 }UlCcchIndInfo;
312
313 typedef struct dlCcchInd
314 {
315    uint16_t      cellId;
316    uint16_t      crnti;
317    DlCcchMsgType msgType;
318    uint8_t       *dlCcchMsg;
319 }DlCcchIndInfo;
320
321
322 /* Functions for slot Ind from MAC to DU APP*/
323 typedef uint16_t (*DuMacSlotInd) ARGS((
324    Pst       *pst,
325    SlotInfo  *slotInfo ));
326
327 /* Functions for stop Ind from MAC to DU APP*/
328 typedef uint16_t (*DuMacStopInd) ARGS((
329    Pst       *pst,
330    MacCellStopInfo  *cellId ));
331
332 /* Functions for mac cell start req */
333 typedef uint16_t (*DuMacCellStartReq) ARGS((
334    Pst               *pst, 
335    MacCellStartInfo  *cellStartInfo ));
336
337 /* Functions for mac cell stop request */
338 typedef uint16_t (*DuMacCellStopReq) ARGS((
339    Pst               *pst,
340    MacCellStopInfo  *cellStopInfo ));
341  
342 /* Function pointers for packing macCellCfg Request and Confirm */
343 typedef int (*packMacCellCfgReq) ARGS((
344    Pst           *pst,
345    MacCellCfg    *macCellCfg ));
346
347 typedef int (*packMacCellCfgConfirm) ARGS((
348    Pst              *pst,
349    MacCellCfgCfm    *macCellCfgCfm ));
350
351 typedef int (*DuMacCellCfgReq) ARGS((
352    Pst        *pst,        
353    MacCellCfg *macCellCfg));
354
355 typedef int (*DuMacCellCfgCfm) ARGS((
356    Pst        *pst,        
357    MacCellCfgCfm *macCellCfgCfm ));
358
359 /* Functions for UL CCCH Ind from MAC to DU APP*/
360 typedef uint16_t (*DuMacUlCcchInd) ARGS((
361    Pst           *pst,
362    UlCcchIndInfo *ulCcchIndInfo ));
363
364 /* Functions for DL CCCH Ind from DU APP to MAC*/
365 typedef uint16_t (*DuMacDlCcchInd) ARGS((
366    Pst           *pst,
367    DlCcchIndInfo *dlCcchIndInfo ));
368
369 extern uint16_t packMacSlotInd(Pst *pst, SlotInfo *slotInfo );
370 extern uint16_t unpackMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf);
371 extern uint16_t duHandleSlotInd(Pst *pst, SlotInfo *slotInfo);
372 extern uint16_t packMacCellStartReq(Pst *pst, MacCellStartInfo *cellStartInfo);
373 extern uint16_t unpackMacCellStartReq(DuMacCellStartReq func, Pst *pst, Buffer *mBuf);
374 extern uint16_t MacHdlCellStartReq(Pst *pst, MacCellStartInfo  *cellStartInfo);
375 extern uint16_t packMacCellStopReq(Pst *pst, MacCellStopInfo  *cellStopInfo);
376 extern uint16_t unpackMacCellStopReq(DuMacCellStopReq func, Pst *pst, Buffer *mBuf);
377 extern uint16_t MacHdlCellStopReq(Pst *pst, MacCellStopInfo  *cellStopInfo);
378 extern int  packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg);
379 extern int MacHdlCellCfgReq(Pst *pst, MacCellCfg *macCellCfg);
380 extern void cmUnpackLwLcMacCellCfg(DuMacCellCfgReq func, Pst *pst, Buffer *mBuf);
381 extern int unpackMacCellCfgCfm(DuMacCellCfgCfm func, Pst *pst, Buffer *mBuf);
382 extern int duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm);
383 extern uint16_t packMacStopInd(Pst *pst, MacCellStopInfo *cellId);
384 extern uint16_t unpackMacStopInd(DuMacStopInd func, Pst *pst, Buffer *mBuf);
385 extern uint16_t duHandleStopInd(Pst *pst, MacCellStopInfo *cellId);
386 extern uint16_t packMacUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo);
387 extern uint16_t unpackMacUlCcchInd(DuMacUlCcchInd func, Pst *pst, Buffer *mBuf);
388 extern uint16_t duHandleUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo);
389 extern uint16_t packMacDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo);
390 extern uint16_t unpackMacDlCcchInd(DuMacDlCcchInd func, Pst *pst, Buffer *mBuf);
391 extern uint16_t MacHdlDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo);
392 uint8_t sendStopIndMacToDuApp();
393 #endif
394
395 /**********************************************************************
396          End of file
397 **********************************************************************/