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