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