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