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