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