Merge "SIB1 optional parameters, Cell start request, stop request and slot indication"
[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 SIB1_MCS  4
34
35 /* Macros for coupling */
36 #define DU_MAC_LC  0
37 #define DU_MAC_TC  1
38 #define DU_MAC_LWLC  2
39
40 /* Event IDs */
41 #define EVENT_MAC_CELL_CONFIG_REQ    200
42 #define EVENT_MAC_CELL_CONFIG_CFM    201
43 #define EVENT_MAC_CELL_START_REQ     202
44 #define EVENT_MAC_CELL_STOP_REQ      203
45 #define EVENT_MAC_SLOT_IND           204
46
47 typedef enum
48 {
49    DUP_MODE_FDD,
50    DUP_MODE_TDD
51 }DuplexMode;
52
53 typedef enum
54 {
55    MAC_GEN_FULL_PBCH_PAYLD,   /* MAC generated the full PBCH Payload */
56    PHY_GEN_TIMING_PBCH_BIT,   /* PHY generates the timing PBCH bits */
57    PHY_GEN_FULL_PBCH_PAYLD    /* PHY generates full PBCH payload */
58 }BchPduOpt;
59
60 typedef enum
61 {
62    LONG_SEQUENCE,
63    SHORT_SEQUENCE
64 }PrachSeqLen;
65
66 typedef enum
67 {
68    UNRESTRICTED,
69    RESTRICTED_SET_TYPE_A,
70    RESTRICTED_SET_TYPE_B
71 }RstSetCfg;
72
73 typedef enum
74 {
75    DONT_REPORT_RSSI,
76    RSSI_UNIT_DBM,
77    RSSI_UNIT_DBFS
78 }RSSIMeasUnit;
79
80 typedef enum
81 {
82    DL_SLOT,
83    UL_SLOT,
84    GUARD_SLOT
85 }SlotConfig;
86
87 typedef enum
88 {
89    TX_PRDCTY_MS_0P5,
90    TX_PRDCTY_MS_0P625,
91    TX_PRDCTY_MS_1,
92    TX_PRDCTY_MS_1P25,
93    TX_PRDCTY_MS_2,
94    TX_PRDCTY_MS_2P5,
95    TX_PRDCTY_MS_5,
96    TX_PRDCTY_MS_10
97 }DlUlTxPeriodicity;
98
99 typedef enum
100 {
101    BETA_PSS_0DB,
102    BETA_PSS_1DB
103 }BetaPss;
104
105 typedef enum 
106 {
107    SSB_PRDCTY_MS_5,
108    SSB_PRDCTY_MS_10,
109    SSB_PRDCTY_MS_20,
110    SSB_PRDCTY_MS_40,
111    SSB_PRDCTY_MS_80,
112    SSB_PRDCTY_MS_160
113 }SSBPeriod;
114
115 typedef struct carrierCfg
116 {
117    Bool  pres;
118    U16   bw;             /* DL/UL bandwidth */
119    U32   freq;           /* Absolute frequency of DL/UL point A in KHz */
120    U16   k0[NUM_NUMEROLOGY];          /* K0 for DL/UL */
121    U16   gridSize[NUM_NUMEROLOGY];    /* DL/UL Grid size for each numerologies */
122    U16   numAnt;         /* Number of Tx/Rx antennas */
123 }CarrierCfg;
124
125 typedef struct ssbCfg
126 {
127    uint32_t    ssbPbchPwr;       /* SSB block power */
128    BchPduOpt   bchPayloadFlag;   /* Options for generation of payload */
129    uint8_t     scsCmn;           /* subcarrier spacing for common */
130    uint16_t    ssbOffsetPointA;  /* SSB subcarrier offset from point A */
131    BetaPss     betaPss;
132    SSBPeriod   ssbPeriod;        /* SSB Periodicity in msec */
133    uint8_t     ssbScOffset;       /* Subcarrier Offset */
134    uint8_t     mibPdu[3];           /* MIB payload */
135    uint32_t    ssbMask[SSB_MASK_SIZE];      /* Bitmap for actually transmitted SSB. */
136    uint8_t     beamId[NUM_SSB];
137    Bool        multCarrBand;     /* Multiple carriers in a band */
138    Bool        multCellCarr;     /* Multiple cells in single carrier */
139 }SsbCfg;
140
141 typedef struct fdmInfo
142 {
143    U16   rootSeqIdx;        /* Root sequence index */
144    U8    numRootSeq;        /* Number of root sequences required for FD */
145    U16   k1;                /* Frequency Offset for each FD */
146    U8    zeroCorrZoneCfg;   /* Zero correlation zone cofig */
147    U8    numUnusedRootSeq;  /* Number of unused root sequence */
148    U8    *unsuedRootSeq;     /* Unused root sequence per FD */
149 }FdmInfo;
150
151 typedef struct prachCfg
152 {
153    Bool          pres;
154    PrachSeqLen   prachSeqLen;         /* RACH Sequence length: Long/short */
155    U8            prachSubcSpacing;    /* Subcarrier spacing of RACH */
156    RstSetCfg     prachRstSetCfg;      /* PRACH restricted set config */
157    U8            prachFdm;            /* PRACH FDM (1,2,4,8) */
158    FdmInfo       fdm[8];
159    U8            ssbPerRach;          /* SSB per RACH occassion */
160    Bool          prachMultCarrBand;    /* Multiple carriers in Band */
161 }PrachCfg;
162
163 typedef struct tddCfg
164 {
165    Bool               pres;
166    DlUlTxPeriodicity  tddPeriod;      /* DL UL Transmission periodicity */
167    SlotConfig         slotCfg[MAXIMUM_TDD_PERIODICITY][MAX_SYMB_PER_SLOT]; 
168 }TDDCfg;
169
170 typedef struct sib1CellCfg
171 {
172    uint8_t  *sib1Pdu;
173    uint16_t sib1PduLen;
174    uint16_t sib1NewTxPeriod;
175    uint16_t sib1RepetitionPeriod;
176    uint8_t coresetZeroIndex;     /* derived from 4 LSB of pdcchSib1 present in MIB */
177    uint8_t searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */
178    uint16_t sib1Mcs;
179 } Sib1CellCfg; 
180
181 typedef struct macCellCfg
182 {
183    U16            transId;
184    U16            cellId;     /* Cell Id */
185    U8             numTlv;     /* Number of configuration TLVs */
186    U8             carrierId;  /* Carrired Index */
187    U16            phyCellId;  /* Physical cell id */
188    DuplexMode     dupType;    /* Duplex type: TDD/FDD */
189    CarrierCfg     dlCarrCfg;  /* DL Carrier configuration */
190    CarrierCfg     ulCarrCfg;  /* UL Carrier configuration */
191    Bool           freqShft;   /* Indicates presence of 7.5kHz frequency shift */
192    SsbCfg         ssbCfg;     /* SSB configuration */          
193    PrachCfg       prachCfg;   /* PRACH Configuration */
194    TDDCfg         tddCfg;     /* TDD periodicity and slot configuration */
195    RSSIMeasUnit   rssiUnit;   /* RSSI measurement unit */
196    Sib1CellCfg    sib1Cfg;
197 }MacCellCfg;
198
199 typedef struct macCellCfgCfm
200 {
201         uint8_t        rsp; 
202    U16            transId;
203 }MacCellCfgCfm;
204
205 typedef struct slotInfo
206 {
207    uint16_t sfn;
208    uint16_t slot;
209 }SlotInfo;
210
211 typedef struct macCellStartInfo
212 {
213    uint16_t cellId;
214 }MacCellStartInfo;
215
216 typedef struct macCellStopInfo
217 {
218    uint16_t cellId;
219 }MacCellStopInfo;
220
221 /* Functions for slot Ind from MAC to DU APP*/
222 typedef uint16_t (*DuMacSlotInd) ARGS((
223    Pst       *pst,
224    SlotInfo  *slotInfo ));
225
226 extern uint16_t packMacSlotInd(Pst *pst, SlotInfo *slotInfo );
227 extern uint16_t unpackMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf);
228 extern uint16_t duHandleSlotInd(Pst *pst, SlotInfo *slotInfo);
229
230 /* Functions for mac cell start req */
231 typedef uint16_t (*DuMacCellStartReq) ARGS((
232    Pst               *pst, 
233    MacCellStartInfo  *cellStartInfo ));
234
235 extern uint16_t packMacCellStartReq(Pst *pst, MacCellStartInfo  *cellStartInfo);
236 extern uint16_t unpackMacCellStartReq(DuMacCellStartReq func, Pst *pst, Buffer *mBuf);
237 extern uint16_t MacHdlCellStartReq(Pst *pst, MacCellStartInfo  *cellStartInfo);
238
239 /* Functions for mac cell stop request */
240 typedef uint16_t (*DuMacCellStopReq) ARGS((
241    Pst               *pst,
242    MacCellStopInfo  *cellStopInfo ));
243  
244 extern uint16_t packMacCellStopReq(Pst *pst, MacCellStopInfo  *cellStopInfo);
245 extern uint16_t unpackMacCellStopReq(DuMacCellStopReq func, Pst *pst, Buffer *mBuf);
246 extern uint16_t MacHdlCellStopReq(Pst *pst, MacCellStopInfo  *cellStopInfo);
247
248 /* Function pointers for packing macCellCfg Request and Confirm */
249 typedef uint16_t (*packMacCellCfgReq) ARGS((
250    Pst           *pst,
251    MacCellCfg    *macCellCfg ));
252
253 typedef uint16_t (*packMacCellCfgConfirm) ARGS((
254    Pst              *pst,
255    MacCellCfgCfm    *macCellCfgCfm ));
256
257 typedef uint16_t (*DuMacCellCfgReq) ARGS((
258    Pst        *pst,        
259    MacCellCfg *macCellCfg));
260
261 typedef uint16_t (*DuMacCellCfgCfm) ARGS((
262    MacCellCfgCfm *macCellCfgCfm ));
263
264 extern uint16_t packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg);
265 extern int MacHdlCellCfgReq(Pst *pst, MacCellCfg *macCellCfg);
266 extern void cmUnpackLwLcMacCellCfg(DuMacCellCfgReq func, Pst *pst, Buffer *mBuf);
267 extern uint16_t unpackMacCellCfgCfm(DuMacCellCfgCfm func, Pst *pst, Buffer *mBuf);
268 extern uint16_t duHandleMacCellCfgCfm(MacCellCfgCfm *macCellCfgCfm);
269
270 #endif
271
272 /**********************************************************************
273          End of file
274 **********************************************************************/