Merge "Added missing triggers and state params for cell up"
[o-du/l2.git] / src / cm / mac_sch_interface.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 /* events */
20 #define EVENT_SCH_CELL_CFG 1
21 #define EVENT_SCH_CELL_CFG_CFM 2
22
23 /* selector */
24 #define MAC_SCH_LC_SELECTOR 0
25 #define MAC_SCH_TC_SELECTOR 1
26 #define MAC_SCH_LWLC_SELECTOR 2
27
28 /*macros*/
29 #define NO_SSB 0
30 #define SSB_TRANSMISSION 1
31 #define SSB_REPEAT 2
32 #define MAX_SSB_IDX 1 /* forcing it as 1 for now. Right value is 64 */
33
34 #define NO_SIB1 0
35 #define SIB1_TRANSMISSION 1
36 #define SIB1_REPITITION 2
37
38 #define MAX_NUM_PRG     1 /* max value should be later 275 */
39 #define MAX_DIG_BF_INTERFACES 0 /* max value should be later 255 */
40 #define MAX_CODEWORDS  1  /* max should be 2 */
41
42 /*structures*/
43
44
45 typedef enum
46 {
47         RSP_OK,
48         RSP_NOK
49 }schMacRsp;
50
51 typedef struct
52 {
53    uint32_t    ssbPbchPwr;       /* SSB block power */
54    uint8_t     scsCommon;           /* subcarrier spacing for common [0-3]*/
55    uint8_t     ssbOffsetPointA;  /* SSB sub carrier offset from point A */
56    SSBPeriod   ssbPeriod;        /* SSB Periodicity in msec */
57    uint8_t     ssbSubcOffset;    /* Subcarrier Offset(Kssb) */
58    uint32_t    nSSBMask[SSB_MASK_SIZE];      /* Bitmap for actually transmitted SSB. */
59 }SchSsbCfg;
60
61 typedef struct bwpCfg
62 {
63    uint8_t subcarrierSpacing;
64    uint8_t cyclicPrefix;
65    uint16_t BWPSize;
66    uint16_t BWPStart;
67 }BwpCfg;
68
69 typedef struct prg
70 {
71    uint16_t pmIdx;
72    uint16_t beamIdx[MAX_DIG_BF_INTERFACES];
73 } Prg;
74
75 typedef struct beamformingInfo
76 {
77    uint16_t numPrgs;
78    uint16_t prgSize;
79    uint8_t  digBfInterfaces;
80    Prg  prg[MAX_NUM_PRG];
81 } BeamformingInfo;
82
83 /* SIB1 PDSCH structures */
84
85 typedef struct codewordinfo
86 {
87    uint16_t targetCodeRate;
88    uint8_t  qamModOrder;
89    uint8_t  mcsIndex;
90    uint8_t  mcsTable;
91    uint8_t  rvIndex;
92    uint32_t tbSize;
93 } CodewordInfo;
94
95 typedef struct dmrsInfo
96 {
97    uint16_t dlDmrsSymbPos;
98    uint8_t  dmrsConfigType;
99    uint16_t dlDmrsScramblingId;
100    uint8_t  scid;
101    uint8_t  numDmrsCdmGrpsNoData;
102    uint16_t dmrsPorts;
103 } DmrsInfo;
104
105 typedef struct pdschFreqAlloc
106 {
107    uint8_t  resourceAlloc;
108    /* since we are using type-1, hence rbBitmap excluded */
109    uint16_t rbStart;
110    uint16_t rbSize;
111    uint8_t  vrbPrbMapping;
112 } PdschFreqAlloc;
113
114 typedef struct pdschTimeAlloc
115 {
116    uint8_t rowIndex;
117    uint8_t startSymbolIndex;
118    uint8_t numSymbols;
119 } PdschTimeAlloc;
120
121 typedef struct txPowerPdschInfo
122 {
123    uint8_t powerControlOffset;
124    uint8_t powerControlOffsetSS;
125 } TxPowerPdschInfo;
126
127 typedef struct sib1PdschCfg
128 {
129    uint16_t pduBitmap;
130    uint16_t rnti;
131    uint16_t pduIndex;
132    BwpCfg sib1PdschBwpCfg;
133    uint8_t numCodewords;
134    CodewordInfo codeword[MAX_CODEWORDS];
135    uint16_t dataScramblingId;
136    uint8_t  numLayers;
137    uint8_t  transmissionScheme;
138    uint8_t  refPoint;
139    DmrsInfo dmrs;
140    PdschFreqAlloc sib1FreqAlloc;
141    PdschTimeAlloc sib1TimeAlloc;
142    BeamformingInfo beamPdschInfo;
143    TxPowerPdschInfo txPdschPower;
144 } Sib1PdschCfg;
145 /* SIB1 PDSCH structures end */
146
147 /* SIB1 interface structure */
148
149 typedef struct coresetCfg
150 {
151    uint8_t coreSet0Size;
152    uint8_t startSymbolIndex;
153    uint8_t durationSymbols;
154    uint8_t freqDomainResource[6];
155    uint8_t cceRegMappingType;
156    uint8_t regBundleSize;
157    uint8_t interleaverSize;
158    uint8_t coreSetType;
159    uint16_t shiftIndex;
160    uint8_t precoderGranularity;
161    uint8_t cceIndex;
162    uint8_t aggregationLevel;
163 } CoresetCfg;
164
165 typedef struct txPowerPdcchInfo
166 {
167    uint8_t powerValue;
168    uint8_t powerControlOffsetSS;
169 } TxPowerPdcchInfo;
170
171 typedef struct dlDCI
172 {
173    uint16_t rnti;
174    uint16_t scramblingId;
175    uint16_t scramblingRnti;
176    uint8_t cceIndex;
177    uint8_t aggregLevel;
178    BeamformingInfo beamPdcchInfo;
179    TxPowerPdcchInfo txPdcchPower;
180    Sib1PdschCfg     *pdschCfg;
181 } DlDCI;
182
183 typedef struct sib1PdcchCfg
184 {
185    BwpCfg sib1PdcchBwpCfg;
186    /* coreset-0 configuration */
187    CoresetCfg sib1Coreset0Cfg;
188
189    uint16_t numDlDci;
190    DlDCI    sib1DlDci; /* as of now its only one DCI, later it will be numDlCi */
191 } Sib1PdcchCfg;
192 /* end of SIB1 PDCCH structures */
193
194 typedef struct
195 {
196    /* parameters recieved from DU-APP */
197    uint16_t sib1PduLen;
198    uint16_t sib1NewTxPeriod;
199    uint16_t sib1RepetitionPeriod;
200    uint8_t  coresetZeroIndex;     /* derived from 4 LSB of pdcchSib1 present in MIB */
201    uint8_t  searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */
202    uint16_t sib1Mcs;
203         
204         /* parameters derived in scheduler */
205         uint8_t n0;
206    Sib1PdcchCfg sib1PdcchCfg;
207    Sib1PdschCfg sib1PdschCfg;
208 }SchSib1Cfg;
209
210 typedef struct schRachCfg
211 {
212    uint8_t      prachCfgIdx; /* PRACH config idx */
213    uint8_t      prachSubcSpacing; /* Subcarrier spacing of RACH */
214    uint8_t      prachSeqLen;  /* Support for PRACH long/short format */
215         uint16_t     msg1FreqStart;     /* Msg1-FrequencyStart */
216         uint8_t      msg1Fdm;             /* PRACH FDM (1,2,4,8) */
217    uint8_t      maxPrachOcassionsInSlot; /* Number of PRACH ocassions per slot */
218    uint8_t      numPrachFdOccasions; /*Number of PRACH ocassions in freq domain */
219    uint16_t     rootSeqIdx;        /* Root sequence index */
220    uint8_t      numRootSeq;        /* Number of root sequences required for FD */
221    uint16_t     k1;                /* Frequency Offset for each FD */
222    uint8_t      ssbPerRach;          /* SSB per RACH occassion */
223    uint8_t      prachMultCarrBand;    /* Presence of Multiple carriers in Band */
224         uint8_t      raContResTmr;        /* RA Contention Resoultion Timer */
225         uint8_t      rsrpThreshSsb;       /* RSRP Threshold SSB */
226    uint8_t      raRspWindow;         /* RA Response Window */
227 }SchRachCfg;
228
229 typedef struct schCellCfg
230 {
231    uint16_t    cellId;     /* Cell Id */
232    uint16_t    phyCellId;  /* Physical cell id */
233         uint8_t     bandwidth;  /* Supported B/W */
234    DuplexMode  dupMode;    /* Duplex type: TDD/FDD */
235         SchSsbCfg   ssbSchCfg;  /* SSB config */
236         SchSib1Cfg  sib1SchCfg; /* SIB1 config */
237    SchRachCfg  schRachCfg; /* PRACH config */
238 }SchCellCfg;
239
240 typedef struct schCellCfgCfm
241 {
242    U16         cellId;     /* Cell Id */
243    schMacRsp   rsp;   
244 }SchCellCfgCfm;
245
246 typedef struct timeDomainAlloc
247 {
248    uint16_t ssbStartSymbIdx;
249         uint16_t ssbSymbolDuration;
250 }TimeDomainAlloc;
251
252 typedef struct freqDomainAlloc
253 {
254    uint16_t ssbStartPrbIdx;
255    uint16_t ssbPrbDuration;
256 }FreqDomainAlloc;
257
258 typedef struct ssbInfo
259 {
260    uint8_t ssbIdx;          /* SSB Index */
261         TimeDomainAlloc tdAlloc; /* Time domain allocation */
262         FreqDomainAlloc fdAlloc; /* Freq domain allocation */
263 }SsbInfo;
264
265 typedef struct sib1AllocInfo
266 {
267    Sib1PdcchCfg sib1PdcchCfg;
268    Sib1PdschCfg sib1PdschCfg;
269 } Sib1AllocInfo;
270
271 /* Interface structure signifying DL broadcast allocation for SSB, SIB1 */
272 typedef struct dlBrdcstAlloc
273 {
274    uint16_t cellId;  /* Cell Id */
275         SlotIndInfo slotIndInfo; /* Slot Info: sfn, slot number */
276         /* Ssb transmission is determined as follows:
277          * 0 : No tranamission
278          * 1 : SSB Transmission
279          * 2 : SSB Repetition */
280         uint8_t ssbTrans;
281         uint8_t ssbIdxSupported;
282         SsbInfo ssbInfo[MAX_SSB_IDX];
283         /* Sib1 transmission is determined as follows:
284          * 0 : No tranamission
285          * 1 : SIB1 Transmission
286          * 2 : SIB1 Repetition */
287         U8 sib1Trans;
288         Sib1AllocInfo sib1Alloc;
289 }DlBrdcstAlloc;
290
291 /* function pointers */
292
293 typedef int (*SchMacDlBrdcstAllocFunc)     ARGS((                     
294    Pst            *pst,           /* Post Structure */                         
295    DlBrdcstAlloc  *dlBrdcstAlloc    /* slot ind Info */                      
296 ));
297
298 typedef int (*SchCellCfgCfmFunc)    ARGS((
299    Pst            *pst,           /* Post Structure */                         
300    SchCellCfgCfm  *schCellCfgCfm  /* Cell Cfg Cfm */
301 ));
302
303 typedef int (*SchCellCfgFunc)    ARGS((
304    Pst            *pst,           /* Post Structure */                         
305    SchCellCfg  *schCellCfg     /* Cell Cfg  */
306 ));
307 /* function declarations */
308 int packMacSchSlotInd(Pst *pst, SlotIndInfo *slotInd);
309 int packSchMacDlBrdcstAlloc(Pst *pst, DlBrdcstAlloc  *dlBrdcstAlloc);
310 EXTERN int packSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
311 EXTERN int packSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
312
313 EXTERN int MacProcDlBrdcstAlloc(Pst *pst, DlBrdcstAlloc *dlBrdcstAlloc);
314 EXTERN int MacProcSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
315 EXTERN int MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
316 EXTERN int SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg);
317 EXTERN int schActvInit(Ent entity, Inst instId, Region region, Reason reason);
318 EXTERN S16 SchSendCfgCfm(Pst *pst, RgMngmt *cfm);
319
320 /**********************************************************************
321   End of file
322  **********************************************************************/
323