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