RARandSib1Transmission
[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 #define EVENT_DL_ALLOC   3 
23 #define EVENT_UL_SCH_INFO       4 
24
25 /* selector */
26 #define MAC_SCH_LC_SELECTOR 0
27 #define MAC_SCH_TC_SELECTOR 1
28 #define MAC_SCH_LWLC_SELECTOR 2
29
30 /*macros*/
31 #define NO_SSB 0
32 #define SSB_TRANSMISSION 1
33 #define SSB_REPEAT 2
34 #define MAX_SSB_IDX 1 /* forcing it as 1 for now. Right value is 64 */
35
36 #define NO_SIB1 0
37 #define SIB1_TRANSMISSION 1
38 #define SIB1_REPITITION 2
39
40 #define MAX_NUM_PRG     1 /* max value should be later 275 */
41 #define MAX_DIG_BF_INTERFACES 0 /* max value should be later 255 */
42 #define MAX_CODEWORDS  1  /* max should be 2 */
43
44 /* Datatype in UL SCH Info */
45 #define SCH_DATATYPE_PUSCH 1
46 #define SCH_DATATYPE_PUSCH_UCI 2
47 #define SCH_DATATYPE_UCI 4
48 #define SCH_DATATYPE_SRS 8
49 #define SCH_DATATYPE_PRACH 16
50
51 /*structures*/
52
53
54 typedef enum
55 {
56         RSP_OK,
57         RSP_NOK
58 }schMacRsp;
59
60 typedef struct
61 {
62    uint32_t    ssbPbchPwr;       /* SSB block power */
63    uint8_t     scsCommon;           /* subcarrier spacing for common [0-3]*/
64    uint8_t     ssbOffsetPointA;  /* SSB sub carrier offset from point A */
65    SSBPeriod   ssbPeriod;        /* SSB Periodicity in msec */
66    uint8_t     ssbSubcOffset;    /* Subcarrier Offset(Kssb) */
67    uint32_t    nSSBMask[SSB_MASK_SIZE];      /* Bitmap for actually transmitted SSB. */
68 }SchSsbCfg;
69
70 typedef struct bwpCfg
71 {
72    uint8_t subcarrierSpacing;
73    uint8_t cyclicPrefix;
74    uint16_t BWPSize;
75    uint16_t BWPStart;
76 }BwpCfg;
77
78 typedef struct prg
79 {
80    uint16_t pmIdx;
81    uint16_t beamIdx[MAX_DIG_BF_INTERFACES];
82 } Prg;
83
84 typedef struct beamformingInfo
85 {
86    uint16_t numPrgs;
87    uint16_t prgSize;
88    uint8_t  digBfInterfaces;
89    Prg  prg[MAX_NUM_PRG];
90 } BeamformingInfo;
91
92 /* SIB1 PDSCH structures */
93
94 typedef struct codewordinfo
95 {
96    uint16_t targetCodeRate;
97    uint8_t  qamModOrder;
98    uint8_t  mcsIndex;
99    uint8_t  mcsTable;
100    uint8_t  rvIndex;
101    uint32_t tbSize;
102 } CodewordInfo;
103
104 typedef struct dmrsInfo
105 {
106    uint16_t dlDmrsSymbPos;
107    uint8_t  dmrsConfigType;
108    uint16_t dlDmrsScramblingId;
109    uint8_t  scid;
110    uint8_t  numDmrsCdmGrpsNoData;
111    uint16_t dmrsPorts;
112 } DmrsInfo;
113
114 typedef struct pdschFreqAlloc
115 {
116    uint8_t  resourceAlloc;
117    /* since we are using type-1, hence rbBitmap excluded */
118    uint16_t rbStart;
119    uint16_t rbSize;
120    uint8_t  vrbPrbMapping;
121 } PdschFreqAlloc;
122
123 typedef struct pdschTimeAlloc
124 {
125    uint8_t rowIndex;
126    uint8_t startSymbolIndex;
127    uint8_t numSymbols;
128 } PdschTimeAlloc;
129
130 typedef struct txPowerPdschInfo
131 {
132    uint8_t powerControlOffset;
133    uint8_t powerControlOffsetSS;
134 } TxPowerPdschInfo;
135
136 typedef struct pdschCfg
137 {
138    uint16_t pduBitmap;
139    uint16_t rnti;
140    uint16_t pduIndex;
141    BwpCfg pdschBwpCfg;
142    uint8_t numCodewords;
143    CodewordInfo codeword[MAX_CODEWORDS];
144    uint16_t dataScramblingId;
145    uint8_t  numLayers;
146    uint8_t  transmissionScheme;
147    uint8_t  refPoint;
148    DmrsInfo dmrs;
149    PdschFreqAlloc freqAlloc;
150    PdschTimeAlloc timeAlloc;
151    BeamformingInfo beamPdschInfo;
152    TxPowerPdschInfo txPdschPower;
153 } PdschCfg;
154 /* SIB1 PDSCH structures end */
155
156 /* SIB1 interface structure */
157
158 typedef struct coresetCfg
159 {
160    uint8_t coreSet0Size;
161    uint8_t startSymbolIndex;
162    uint8_t durationSymbols;
163    uint8_t freqDomainResource[6];
164    uint8_t cceRegMappingType;
165    uint8_t regBundleSize;
166    uint8_t interleaverSize;
167    uint8_t coreSetType;
168    uint16_t shiftIndex;
169    uint8_t precoderGranularity;
170    uint8_t cceIndex;
171    uint8_t aggregationLevel;
172 } CoresetCfg;
173
174 typedef struct txPowerPdcchInfo
175 {
176    uint8_t powerValue;
177    uint8_t powerControlOffsetSS;
178 } TxPowerPdcchInfo;
179
180 typedef struct dlDCI
181 {
182    uint16_t rnti;
183    uint16_t scramblingId;
184    uint16_t scramblingRnti;
185    uint8_t cceIndex;
186    uint8_t aggregLevel;
187    BeamformingInfo beamPdcchInfo;
188    TxPowerPdcchInfo txPdcchPower;
189    PdschCfg     *pdschCfg;
190 } DlDCI;
191
192 typedef struct pdcchCfg
193 {
194    BwpCfg pdcchBwpCfg;
195    /* coreset-0 configuration */
196    CoresetCfg coreset0Cfg;
197
198    uint16_t numDlDci;
199    DlDCI    dci; /* as of now its only one DCI, later it will be numDlCi */
200 } PdcchCfg;
201 /* end of SIB1 PDCCH structures */
202
203 typedef struct
204 {
205    /* parameters recieved from DU-APP */
206    uint16_t sib1PduLen;
207    uint16_t sib1NewTxPeriod;
208    uint16_t sib1RepetitionPeriod;
209    uint8_t  coresetZeroIndex;     /* derived from 4 LSB of pdcchSib1 present in MIB */
210    uint8_t  searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */
211    uint16_t sib1Mcs;
212         
213         /* parameters derived in scheduler */
214         uint8_t n0;
215    PdcchCfg sib1PdcchCfg;
216    PdschCfg sib1PdschCfg;
217 }SchSib1Cfg;
218
219 typedef struct schRachCfg
220 {
221    uint8_t      prachCfgIdx; /* PRACH config idx */
222    uint8_t      prachSubcSpacing; /* Subcarrier spacing of RACH */
223         uint16_t     msg1FreqStart;     /* Msg1-FrequencyStart */
224         uint8_t      msg1Fdm;             /* PRACH FDM (1,2,4,8) */
225    uint16_t     rootSeqIdx;        /* Root sequence index */
226    uint8_t      numRootSeq;        /* Number of root sequences required for FD */
227    uint16_t     k1;                /* Frequency Offset for each FD */
228    uint8_t      ssbPerRach;          /* SSB per RACH occassion */
229    uint8_t      prachMultCarrBand;    /* Presence of Multiple carriers in Band */
230         uint8_t      raContResTmr;        /* RA Contention Resoultion Timer */
231         uint8_t      rsrpThreshSsb;       /* RSRP Threshold SSB */
232    uint8_t      raRspWindow;         /* RA Response Window */
233 }SchRachCfg;
234
235 typedef struct schBwpParams
236 {
237    uint16_t firstPrb;
238    uint16_t numPrb;
239         uint8_t  scs;
240         uint8_t  cyclicPrefix;
241 }SchBwpParams;
242
243 typedef struct schCandidatesInfo
244 {
245    uint8_t aggLevel1;
246    uint8_t aggLevel2;
247    uint8_t aggLevel4;
248    uint8_t aggLevel8;
249    uint8_t aggLevel16;
250 }SchCandidatesInfo;
251
252 typedef struct schSearchSpaceCfg
253 {
254    uint8_t searchSpaceId;
255         uint8_t coresetId;
256         uint16_t monitoringSlot;
257         uint16_t duration;
258         uint16_t monitoringSymbol;
259         SchCandidatesInfo candidate;
260 }SchSearchSpaceCfg;
261
262 typedef struct schPdcchCfgCmn
263 {
264    SchSearchSpaceCfg raSearchSpace;
265 }SchPdcchCfgCmn;
266
267 typedef struct schBwpDlCfg
268 {
269    SchBwpParams   bwp;
270         SchPdcchCfgCmn pdcchCommon;
271 }SchBwpDlCfg;
272
273 typedef struct schCellCfg
274 {
275    uint16_t    cellId;     /* Cell Id */
276    uint16_t    phyCellId;  /* Physical cell id */
277         uint8_t     bandwidth;  /* Supported B/W */
278    DuplexMode  dupMode;    /* Duplex type: TDD/FDD */
279         SchSsbCfg   ssbSchCfg;  /* SSB config */
280         SchSib1Cfg  sib1SchCfg; /* SIB1 config */
281    SchRachCfg  schRachCfg; /* PRACH config */
282         SchBwpDlCfg    schInitialBwp;
283 }SchCellCfg;
284
285 typedef struct schCellCfgCfm
286 {
287    U16         cellId;     /* Cell Id */
288    schMacRsp   rsp;   
289 }SchCellCfgCfm;
290
291 typedef struct timeDomainAlloc
292 {
293    uint16_t ssbStartSymbIdx;
294         uint16_t ssbSymbolDuration;
295 }TimeDomainAlloc;
296
297 typedef struct freqDomainAlloc
298 {
299    uint16_t ssbStartPrbIdx;
300    uint16_t ssbPrbDuration;
301 }FreqDomainAlloc;
302
303 typedef struct ssbInfo
304 {
305    uint8_t ssbIdx;          /* SSB Index */
306         TimeDomainAlloc tdAlloc; /* Time domain allocation */
307         FreqDomainAlloc fdAlloc; /* Freq domain allocation */
308 }SsbInfo;
309
310 typedef struct sib1AllocInfo
311 {
312    PdcchCfg sib1PdcchCfg;
313    PdschCfg sib1PdschCfg;
314 } Sib1AllocInfo;
315
316 typedef struct prachSchInfo
317 {
318         uint8_t  numPrachOcas;   /* Num Prach Ocassions */
319    uint8_t  prachFormat;    /* PRACH Format */
320    uint8_t  numRa;          /* Freq domain ocassion */
321    uint8_t  prachStartSymb; /* Freq domain ocassion */
322 }PrachSchInfo;
323
324 /* Interface structure signifying DL broadcast allocation for SSB, SIB1 */
325 typedef struct dlBrdcstAlloc
326 {
327         /* Ssb transmission is determined as follows:
328          * 0 : No tranamission
329          * 1 : SSB Transmission
330          * 2 : SSB Repetition */
331         uint8_t ssbTrans;
332         uint8_t ssbIdxSupported;
333         SsbInfo ssbInfo[MAX_SSB_IDX];
334         /* Sib1 transmission is determined as follows:
335          * 0 : No tranamission
336          * 1 : SIB1 Transmission
337          * 2 : SIB1 Repetition */
338         U8 sib1Trans;
339         Sib1AllocInfo sib1Alloc;
340 }DlBrdcstAlloc;
341
342 typedef struct rarInfo
343 {
344    uint16_t raRnti;
345         uint8_t  RAPID;
346         uint16_t ta;
347         uint16_t msg3StartRb;
348         uint8_t  msg3NumRb;
349         uint16_t tcrnti;
350         uint8_t rarPdu[8];
351         uint8_t rarPduLen;
352 }RarInfo;
353
354 typedef struct rarAlloc
355 {
356    RarInfo rarInfo;
357    PdcchCfg rarPdcchCfg;
358    PdschCfg rarPdschCfg;
359 }RarAlloc;
360
361 typedef struct dlAlloc
362 {
363    uint16_t cellId;  /* Cell Id */
364         SlotIndInfo slotIndInfo; /* Slot Info: sfn, slot number */
365
366         /* Allocation for broadcast messages */
367    uint8_t isBroadcastPres;
368         DlBrdcstAlloc brdcstAlloc;
369
370         /* Allocation for RAR message */
371         uint8_t isRarPres;
372         RarAlloc rarAlloc;
373 }DlAlloc;
374 typedef struct ulSchInfo
375 {
376    uint16_t      cellId;         /* Cell Id */
377         SlotIndInfo   slotIndInfo;    /* Slot Info: sfn, slot number */
378         uint8_t       dataType;       /* Type of info being scheduled */
379         PrachSchInfo  prachSchInfo;   /* Prach scheduling info */
380 }UlSchInfo;
381
382 typedef struct rachIndInfo
383 {
384    uint16_t    cellId;
385    uint16_t    crnti;
386    SlotIndInfo timingInfo;
387    uint8_t     slotIdx;
388    uint8_t     symbolIdx;
389    uint8_t     freqIdx;
390    uint8_t     preambleIdx;
391    uint16_t    timingAdv;
392 }RachIndInfo;
393
394 /* function pointers */
395
396 typedef int (*SchCellCfgCfmFunc)    ARGS((
397    Pst            *pst,           /* Post Structure */                         
398    SchCellCfgCfm  *schCellCfgCfm  /* Cell Cfg Cfm */
399 ));
400
401 typedef int (*SchCellCfgFunc)    ARGS((
402    Pst            *pst,           /* Post Structure */                         
403    SchCellCfg  *schCellCfg     /* Cell Cfg  */
404 ));
405
406 typedef int (*SchMacDlAllocFunc)     ARGS((                     
407    Pst            *pst,       /* Post Structure */                         
408    DlAlloc        *dlAlloc    /* dl allocation Info */                      
409 ));
410
411 typedef int (*SchMacUlSchInfoFunc)     ARGS((                     
412    Pst            *pst,           /* Post Structure */                         
413    UlSchInfo      *ulSchInfo    /* UL Sch  Info */                      
414 ));
415
416 /* function declarations */
417 int packMacSchSlotInd(Pst *pst, SlotIndInfo *slotInd);
418 int packSchMacDlAlloc(Pst *pst, DlAlloc  *dlAlloc);
419 int packSchMacUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo);
420 EXTERN int packSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
421 EXTERN int packSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
422
423 EXTERN int MacProcDlAlloc(Pst *pst, DlAlloc *dlAlloc);
424 EXTERN int MacProcSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
425 EXTERN int MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
426 EXTERN int SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg);
427 EXTERN int schActvInit(Ent entity, Inst instId, Region region, Reason reason);
428 EXTERN S16 SchSendCfgCfm(Pst *pst, RgMngmt *cfm);
429 EXTERN int MacProcUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo);
430 typedef int (*MacSchRachIndFunc)(Pst *pst, RachIndInfo *rachInd);
431 int packMacSchRachInd(Pst *pst, RachIndInfo *rachInd);
432 int macSchRachInd(Pst *pst, RachIndInfo *rachInd);
433
434 /**********************************************************************
435   End of file
436  **********************************************************************/
437