Merge "UE CB creation at MAC and SCH [Issue-ID: ODUHIGH-177]"
[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 #define EVENT_RACH_IND_TO_SCH        5
25 #define EVENT_CRC_IND_TO_SCH         6
26 #define EVENT_DL_RLC_BO_INFO_TO_SCH  7
27 #define EVENT_UE_CREATE_REQ_TO_SCH   8
28 #define EVENT_UE_CREATE_RSP_TO_MAC   9
29
30
31 /*macros*/
32 #define NO_SSB 0
33 #define SSB_TRANSMISSION 1
34 #define SSB_REPEAT 2
35 #define MAX_SSB_IDX 1 /* forcing it as 1 for now. Right value is 64 */
36
37 #define NO_SIB1 0
38 #define SIB1_TRANSMISSION 1
39 #define SIB1_REPITITION 2
40
41 #define MAX_NUM_PRG     1 /* max value should be later 275 */
42 #define MAX_DIG_BF_INTERFACES 0 /* max value should be later 255 */
43 #define MAX_CODEWORDS  1  /* max should be 2 */
44 #define SCH_HARQ_PROC_ID 1 /* harq proc id */
45 #define SCH_ALLOC_TYPE_1 1 /*sch res alloc type */
46
47 /* Datatype in UL SCH Info */
48 #define SCH_DATATYPE_PUSCH 1
49 #define SCH_DATATYPE_PUSCH_UCI 2
50 #define SCH_DATATYPE_UCI 4
51 #define SCH_DATATYPE_SRS 8
52 #define SCH_DATATYPE_PRACH 16
53
54 #define MAX_NUMBER_OF_CRC_IND_BITS 1
55 #define MAX_NUM_LOGICAL_CHANNELS   11
56 /* can we have a common numslot numscs between mac sch */
57 #define MAX_SLOTS 10
58 #define MAX_SFN   1024
59 #define MAX_NUM_SR_CFG_PER_CELL_GRP 8   /* Max number of scheduling request config per cell group */
60 #define MAX_NUM_TAGS 4                  /* Max number of timing advance groups */
61 #define MAX_NUM_BWP  4                  /* Max number of BWP per serving cell */
62 #define MAX_NUM_CRSET  3                /* Max number of control resource set in add/modify/release list */
63 #define MAX_NUM_SEARCH_SPC  10          /* Max number of search space in add/modify/release list */
64 #define FREQ_DOM_RSRC_SIZE  6           /* i.e. 6 bytes because Size of frequency domain resource is 45 bits */
65 #define MONITORING_SYMB_WITHIN_SLOT_SIZE 2  /* i.e. 2 bytes because size of monitoring symbols within slot is 14 bits */
66 #define MAX_NUM_DL_ALLOC 16             /* Max number of pdsch time domain downlink allocation */
67 #define MAX_NUM_UL_ALLOC 16             /* Max number of pusch time domain uplink allocation */
68
69 #define SD_SIZE   3
70 #define CCCH_LCID  0
71
72 #define ADD_DELTA_TO_TIME(crntTime, toFill, incr)          \
73 {                                                          \
74    if ((crntTime.slot + incr) > (MAX_SLOTS - 1))           \
75    {                                                       \
76       toFill.sfn = (crntTime.sfn + 1);                     \
77    }                                                       \
78    else                                                    \
79    {                                                       \
80       toFill.sfn = crntTime.sfn;                           \
81    }                                                       \
82    toFill.slot = (crntTime.slot + incr) % MAX_SLOTS;       \
83    if (toFill.sfn >= MAX_SFN)                              \
84    {                                                       \
85       toFill.sfn%=MAX_SFN;                                 \
86    }                                                       \
87 }
88
89 /*structures*/
90 typedef enum
91 {
92    UNSPECIFIED_CAUSE,
93    INVALID_PARAM_VALUE,
94    RESOURCE_UNAVAILABLE,
95    SYSTEM_ERROR
96 }SchFailureCause;
97
98 typedef enum
99 {
100    SR_PROHIBIT_MS1,
101    SR_PROHIBIT_MS2,
102    SR_PROHIBIT_MS4,
103    SR_PROHIBIT_MS8,
104    SR_PROHIBIT_MS16,
105    SR_PROHIBIT_MS32,
106    SR_PROHIBIT_MS64,
107    SR_PROHIBIT_MS128
108 }SchSrProhibitTimer;
109
110 typedef enum
111 {
112    SR_TRANS_MAX_N4,
113    SR_TRANS_MAX_N8,
114    SR_TRANS_MAX_N16,
115    SR_TRANS_MAX_N32,
116    SR_TRANS_MAX_N64,
117    SR_TRANS_MAX_SPARE3,
118    SR_TRANS_MAX_SPARE2,
119    SR_TRANS_MAX_SPARE1
120 }SchSrTransMax;
121
122 typedef enum
123 {
124    TIME_ALIGNMENT_TIMER_MS500,
125    TIME_ALIGNMENT_TIMER_MS750,
126    TIME_ALIGNMENT_TIMER_MS1280,
127    TIME_ALIGNMENT_TIMER_MS1920,
128    TIME_ALIGNMENT_TIMER_MS2560,
129    TIME_ALIGNMENT_TIMER_MS5120,
130    TIME_ALIGNMENT_TIMER_MS10240,
131    TIME_ALIGNMENT_TIMER_INFINITE
132 }SchTimeAlignmentTimer;
133
134 typedef enum
135 {
136    PHR_PERIODIC_TIMER_SF10,
137    PHR_PERIODIC_TIMER_SF20,
138    PHR_PERIODIC_TIMER_SF50,
139    PHR_PERIODIC_TIMER_SF100,
140    PHR_PERIODIC_TIMER_SF200,
141    PHR_PERIODIC_TIMER_SF500,
142    PHR_PERIODIC_TIMER_SF1000,
143    PHR_PERIODIC_TIMER_INFINITE
144 }SchPhrPeriodicTimer;
145
146 typedef enum
147 {
148    PHR_PROHIBIT_TIMER_SF0,
149    PHR_PROHIBIT_TIMER_SF10,
150    PHR_PROHIBIT_TIMER_SF20,
151    PHR_PROHIBIT_TIMER_SF50,
152    PHR_PROHIBIT_TIMER_SF100,
153    PHR_PROHIBIT_TIMER_SF200,
154    PHR_PROHIBIT_TIMER_SF500,
155    PHR_PROHIBIT_TIMER_SF1000
156 }SchPhrProhibitTimer;
157
158 typedef enum
159 {
160    PHR_TX_PWR_FACTOR_CHANGE_DB1,
161    PHR_TX_PWR_FACTOR_CHANGE_DB3,
162    PHR_TX_PWR_FACTOR_CHANGE_DB6,
163    PHR_TX_PWR_FACTOR_CHANGE_INFINITE
164 }SchPhrTxPwrFactorChange;
165
166 typedef enum
167 {
168    PHR_MODE_REAL,
169    PHR_MODE_VIRTUAL
170 }SchPhrModeOtherCG;
171
172 typedef enum
173 {
174    HARQ_ACK_CODEBOOK_SEMISTATIC,
175    HARQ_ACK_CODEBOOK_DYNAMIC
176 }SchPdschHarqAckCodebook;
177
178 typedef enum
179 {
180    NUM_HARQ_PROC_FOR_PDSCH_N2,
181    NUM_HARQ_PROC_FOR_PDSCH_N4,
182    NUM_HARQ_PROC_FOR_PDSCH_N6,
183    NUM_HARQ_PROC_FOR_PDSCH_N10,
184    NUM_HARQ_PROC_FOR_PDSCH_N16
185 }SchNumHarqProcForPdsch;
186
187 typedef enum
188 {
189    MAX_CODE_BLOCK_GROUP_PER_TB_N2,
190    MAX_CODE_BLOCK_GROUP_PER_TB_N4,
191    MAX_CODE_BLOCK_GROUP_PER_TB_N6,
192    MAX_CODE_BLOCK_GROUP_PER_TB_N8
193 }SchMaxCodeBlkGrpPerTB;
194
195 typedef enum
196 {
197    PDSCH_X_OVERHEAD_XOH_6,
198    PDSCH_X_OVERHEAD_XOH_12,
199    PDSCH_X_OVERHEAD_XOH_18
200 }SchPdschXOverhead;
201
202 typedef enum
203 {
204    DMRS_ADDITIONAL_POS0,
205    DMRS_ADDITIONAL_POS1,
206    DMRS_ADDITIONAL_POS3
207 }SchDmrsAdditionPosition;
208
209 typedef enum
210 {
211    RESOURCE_ALLOCTION_TYPE_0,
212    RESOURCE_ALLOCTION_TYPE_1,
213    RESOURCE_ALLOCTION_DYN_SWITCH
214 }SchResourceAllocType;
215
216 typedef enum
217 {
218    TIME_DOMAIN_RSRC_ALLOC_MAPPING_TYPE_A,
219    TIME_DOMAIN_RSRC_ALLOC_MAPPING_TYPE_B
220 }SchTimeDomRsrcAllocMappingType;
221
222 typedef enum
223 {
224    ENABLED_TRANSFORM_PRECODER,
225    DISABLED_TRANSFORM_PRECODER
226 }SchTransformPrecoder;
227
228 typedef enum
229 {
230    INTERLEAVED_CCE_REG_MAPPING,
231    NONINTERLEAVED_CCE_REG_MAPPING
232 }SchREGMappingType;
233
234 typedef enum
235 {
236    SLOT_PERIODICITY_AND_OFFSET_SL_1,
237    SLOT_PERIODICITY_AND_OFFSET_SL_2,
238    SLOT_PERIODICITY_AND_OFFSET_SL_4,
239    SLOT_PERIODICITY_AND_OFFSET_SL_5,
240    SLOT_PERIODICITY_AND_OFFSET_SL_8,
241    SLOT_PERIODICITY_AND_OFFSET_SL_10,
242    SLOT_PERIODICITY_AND_OFFSET_SL_16,
243    SLOT_PERIODICITY_AND_OFFSET_SL_20,
244    SLOT_PERIODICITY_AND_OFFSET_SL_40,
245    SLOT_PERIODICITY_AND_OFFSET_SL_80,
246    SLOT_PERIODICITY_AND_OFFSET_SL_160,
247    SLOT_PERIODICITY_AND_OFFSET_SL_320,
248    SLOT_PERIODICITY_AND_OFFSET_SL_640,
249    SLOT_PERIODICITY_AND_OFFSET_SL_1280,
250    SLOT_PERIODICITY_AND_OFFSET_SL_2560
251 }SchMSlotPeriodAndOffset;
252
253 typedef enum
254 {
255    SAME_AS_REG_BUNDLE,
256    ALL_CONTIGUOUS_RB
257 }SchPrecoderGranul;
258
259 typedef enum
260 {
261    SEARCH_SPACE_TYPE_COMMON,
262    SEARCH_SPACE_TYPE_UE_SPECIFIC
263 }SchSearchSpaceType;
264
265 typedef enum
266 {
267    AGGREGATION_LEVEL_N0,
268    AGGREGATION_LEVEL_N1,
269    AGGREGATION_LEVEL_N2,
270    AGGREGATION_LEVEL_N3,
271    AGGREGATION_LEVEL_N4,
272    AGGREGATION_LEVEL_N5,
273    AGGREGATION_LEVEL_N6,
274    AGGREGATION_LEVEL_N8
275 }SchAggrLevel;
276
277 typedef enum
278 {
279    RBG_SIZE_CONFIG_1,
280    RBG_SIZE_CONFIG_2
281 }SchRBGSize;
282
283 typedef enum
284 {
285    CODE_WORDS_SCHED_BY_DCI_N1,
286    CODE_WORDS_SCHED_BY_DCI_N2
287 }SchCodeWordsSchedByDci;
288
289 typedef enum
290 {
291    STATIC_BUNDLING_TYPE,
292    DYNAMIC_BUNDLING_TYPE
293 }SchBundlingType;
294
295 typedef enum
296 {
297    RSP_OK,
298    RSP_NOK
299 }SchMacRsp;
300
301 typedef struct timeDomainAlloc
302 {
303    uint16_t startSymb;
304    uint16_t numSymb;
305 }TimeDomainAlloc;
306
307 typedef struct freqDomainAlloc
308 {
309    uint16_t startPrb;
310    uint16_t numPrb;
311 }FreqDomainAlloc;
312
313
314 typedef struct
315 {
316    uint32_t    ssbPbchPwr;       /* SSB block power */
317    uint8_t     scsCommon;           /* subcarrier spacing for common [0-3]*/
318    uint8_t     ssbOffsetPointA;  /* SSB sub carrier offset from point A */
319    SSBPeriod   ssbPeriod;        /* SSB Periodicity in msec */
320    uint8_t     ssbSubcOffset;    /* Subcarrier Offset(Kssb) */
321    uint32_t    nSSBMask[SSB_MASK_SIZE];      /* Bitmap for actually transmitted SSB. */
322 }SchSsbCfg;
323
324 typedef struct bwpCfg
325 {
326    uint8_t         subcarrierSpacing;
327    uint8_t         cyclicPrefix;
328    FreqDomainAlloc freqAlloc;   
329 }BwpCfg;
330
331 typedef struct prg
332 {
333    uint16_t pmIdx;
334    uint16_t beamIdx[MAX_DIG_BF_INTERFACES];
335 } Prg;
336
337 typedef struct beamformingInfo
338 {
339    uint16_t numPrgs;
340    uint16_t prgSize;
341    uint8_t  digBfInterfaces;
342    Prg  prg[MAX_NUM_PRG];
343 } BeamformingInfo;
344
345 /* SIB1 PDSCH structures */
346
347 typedef struct codewordinfo
348 {
349    uint16_t targetCodeRate;
350    uint8_t  qamModOrder;
351    uint8_t  mcsIndex;
352    uint8_t  mcsTable;
353    uint8_t  rvIndex;
354    uint32_t tbSize;
355 } CodewordInfo;
356
357 typedef struct dmrsInfo
358 {
359    uint16_t dlDmrsSymbPos;
360    uint8_t  dmrsConfigType;
361    uint16_t dlDmrsScramblingId;
362    uint8_t  scid;
363    uint8_t  numDmrsCdmGrpsNoData;
364    uint16_t dmrsPorts;
365    uint8_t mappingType;
366    uint8_t nrOfDmrsSymbols;
367    uint8_t dmrsAddPos;
368 } DmrsInfo;
369
370 typedef struct pdschFreqAlloc
371 {
372    uint8_t  resourceAllocType;
373    /* since we are using type-1, hence rbBitmap excluded */
374    FreqDomainAlloc freqAlloc;
375    uint8_t  vrbPrbMapping;
376 } PdschFreqAlloc;
377
378 typedef struct pdschTimeAlloc
379 {
380    uint8_t         rowIndex;
381    TimeDomainAlloc timeAlloc;
382 } PdschTimeAlloc;
383
384 typedef struct txPowerPdschInfo
385 {
386    uint8_t powerControlOffset;
387    uint8_t powerControlOffsetSS;
388 } TxPowerPdschInfo;
389
390 typedef struct pdschCfg
391 {
392    uint16_t         pduBitmap;
393    uint16_t         rnti;
394    uint16_t         pduIndex;
395    uint8_t          numCodewords;
396    CodewordInfo     codeword[MAX_CODEWORDS];
397    uint16_t         dataScramblingId;
398    uint8_t          numLayers;
399    uint8_t          transmissionScheme;
400    uint8_t          refPoint;
401    DmrsInfo         dmrs;
402    PdschFreqAlloc   pdschFreqAlloc;
403    PdschTimeAlloc   pdschTimeAlloc;
404    BeamformingInfo  beamPdschInfo;
405    TxPowerPdschInfo txPdschPower;
406 } PdschCfg;
407 /* SIB1 PDSCH structures end */
408
409 /* SIB1 interface structure */
410
411 typedef struct coresetCfg
412 {
413    uint8_t coreSet0Size;
414    uint8_t startSymbolIndex;
415    uint8_t durationSymbols;
416    uint8_t freqDomainResource[6];
417    uint8_t cceRegMappingType;
418    uint8_t regBundleSize;
419    uint8_t interleaverSize;
420    uint8_t coreSetType;
421    uint16_t shiftIndex;
422    uint8_t precoderGranularity;
423    uint8_t cceIndex;
424    uint8_t aggregationLevel;
425 } CoresetCfg;
426
427 typedef struct txPowerPdcchInfo
428 {
429    uint8_t powerValue;
430    uint8_t powerControlOffsetSS;
431 } TxPowerPdcchInfo;
432
433 typedef struct dlDCI
434 {
435    uint16_t rnti;
436    uint16_t scramblingId;
437    uint16_t scramblingRnti;
438    uint8_t cceIndex;
439    uint8_t aggregLevel;
440    BeamformingInfo beamPdcchInfo;
441    TxPowerPdcchInfo txPdcchPower;
442    PdschCfg     *pdschCfg;
443 } DlDCI;
444
445 typedef struct pdcchCfg
446 {
447    /* coreset-0 configuration */
448    CoresetCfg coreset0Cfg;
449
450    uint16_t numDlDci;
451    DlDCI    dci; /* as of now its only one DCI, later it will be numDlCi */
452 } PdcchCfg;
453 /* end of SIB1 PDCCH structures */
454
455 typedef struct
456 {
457    /* parameters recieved from DU-APP */
458    uint16_t sib1PduLen;
459    uint16_t sib1NewTxPeriod;
460    uint16_t sib1RepetitionPeriod;
461    uint8_t  coresetZeroIndex;     /* derived from 4 LSB of pdcchSib1 present in MIB */
462    uint8_t  searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */
463    uint16_t sib1Mcs;
464
465    /* parameters derived in scheduler */
466    uint8_t n0;
467    BwpCfg bwp;
468    PdcchCfg sib1PdcchCfg;
469    PdschCfg sib1PdschCfg;
470 }SchSib1Cfg;
471
472 typedef struct schRachCfg
473 {
474    uint8_t      prachCfgIdx;       /* PRACH config idx */
475    uint8_t      prachSubcSpacing;  /* Subcarrier spacing of RACH */
476    uint16_t     msg1FreqStart;     /* Msg1-FrequencyStart */
477    uint8_t      msg1Fdm;           /* PRACH FDM (1,2,4,8) */
478    uint8_t      rootSeqLen;        /* root sequence length */
479    uint16_t     rootSeqIdx;        /* Root sequence index */
480    uint8_t      numRootSeq;        /* Number of root sequences required for FD */
481    uint16_t     k1;                /* Frequency Offset for each FD */
482    uint8_t      ssbPerRach;        /* SSB per RACH occassion */
483    uint8_t      prachMultCarrBand; /* Presence of Multiple carriers in Band */
484    uint8_t      raContResTmr;      /* RA Contention Resoultion Timer */
485    uint8_t      rsrpThreshSsb;     /* RSRP Threshold SSB */
486    uint8_t      raRspWindow;       /* RA Response Window */
487 }SchRachCfg;
488
489 typedef struct schBwpParams
490 {
491    FreqDomainAlloc freqAlloc;
492    uint8_t         scs;
493    uint8_t         cyclicPrefix;
494 }SchBwpParams;
495
496 typedef struct schCandidatesInfo
497 {
498    uint8_t aggLevel1;
499    uint8_t aggLevel2;
500    uint8_t aggLevel4;
501    uint8_t aggLevel8;
502    uint8_t aggLevel16;
503 }SchCandidatesInfo;
504
505 typedef struct schSearchSpaceCfg
506 {
507    uint8_t searchSpaceId;
508    uint8_t coresetId;
509    uint16_t monitoringSlot;
510    uint16_t duration;
511    uint16_t monitoringSymbol;
512    SchCandidatesInfo candidate;
513 }SchSearchSpaceCfg;
514
515 typedef struct schPdcchCfgCmn
516 {
517    SchSearchSpaceCfg commonSearchSpace;
518    uint8_t raSearchSpaceId;
519 }SchPdcchCfgCmn;
520
521 typedef struct schPdschCfgCmn
522 {
523    uint8_t k0;
524    uint8_t mappingType;
525    uint8_t startSymbol;
526    uint8_t lengthSymbol;
527 }SchPdschCfgCmn;
528
529 typedef struct schPucchCfgCmn
530 {
531    uint8_t pucchResourceCommon;
532    uint8_t pucchGroupHopping;
533 }SchPucchCfgCmn;
534
535 typedef struct schPuschCfgCmn
536 {
537    uint8_t k2;
538    uint8_t mappingType;
539    uint8_t startSymbol;
540    uint8_t lengthSymbol;
541 }SchPuschCfgCmn;
542
543 typedef struct schBwpDlCfg
544 {
545    SchBwpParams   bwp;
546    SchPdcchCfgCmn pdcchCommon;
547    SchPdschCfgCmn pdschCommon;
548 }SchBwpDlCfg;
549
550 typedef struct schBwpUlCfg
551 {
552    SchBwpParams   bwp;
553    SchPucchCfgCmn pucchCommon;
554    SchPuschCfgCmn puschCommon;
555 }SchBwpUlCfg;
556
557 typedef struct schCellCfg
558 {
559    uint16_t    cellId;           /* Cell Id */
560    uint16_t    phyCellId;        /* Physical cell id */
561    uint8_t     bandwidth;        /* Supported B/W */
562    DuplexMode  dupMode;          /* Duplex type: TDD/FDD */
563    SchSsbCfg   ssbSchCfg;        /* SSB config */
564    SchSib1Cfg  sib1SchCfg;       /* SIB1 config */
565    SchRachCfg  schRachCfg;       /* PRACH config */
566    SchBwpDlCfg schInitialDlBwp;  /* Initial DL BWP */
567    SchBwpUlCfg schInitialUlBwp;  /* Initial UL BWP */
568    uint8_t     puschMu;          /* PUSCH MU */
569 }SchCellCfg;
570
571 typedef struct schCellCfgCfm
572 {
573    U16         cellId;     /* Cell Id */
574    SchMacRsp   rsp;   
575 }SchCellCfgCfm;
576
577 typedef struct ssbInfo
578 {
579    uint8_t         ssbIdx;          /* SSB Index */
580    TimeDomainAlloc tdAlloc; /* Time domain allocation */
581    FreqDomainAlloc fdAlloc; /* Freq domain allocation */
582 }SsbInfo;
583
584 typedef struct sib1AllocInfo
585 {
586    BwpCfg bwp;
587    PdcchCfg sib1PdcchCfg;
588    PdschCfg sib1PdschCfg;
589 } Sib1AllocInfo;
590
591 typedef struct prachSchInfo
592 {
593    uint8_t  numPrachOcas;   /* Num Prach Ocassions */
594    uint8_t  prachFormat;    /* PRACH Format */
595    uint8_t  numRa;          /* Freq domain ocassion */
596    uint8_t  prachStartSymb; /* Freq domain ocassion */
597 }PrachSchInfo;
598
599 /* Interface structure signifying DL broadcast allocation for SSB, SIB1 */
600 typedef struct dlBrdcstAlloc
601 {
602    /* Ssb transmission is determined as follows:
603     * 0 : No tranamission
604     * 1 : SSB Transmission
605     * 2 : SSB Repetition */
606    uint8_t ssbTrans;
607    uint8_t ssbIdxSupported;
608    SsbInfo ssbInfo[MAX_SSB_IDX];
609    /* Sib1 transmission is determined as follows:
610     * 0 : No tranamission
611     * 1 : SIB1 Transmission
612     * 2 : SIB1 Repetition */
613    U8 sib1Trans;
614    Sib1AllocInfo sib1Alloc;
615 }DlBrdcstAlloc;
616
617 typedef struct rarInfo
618 {
619    uint16_t        raRnti;
620    uint8_t         RAPID;
621    uint16_t        ta;
622    FreqDomainAlloc msg3FreqAlloc;
623    uint16_t        tcrnti;
624    uint8_t         rarPdu[8];
625    uint8_t         rarPduLen;
626 }RarInfo;
627
628 typedef struct rarAlloc
629 {
630    RarInfo rarInfo;
631    BwpCfg  bwp;
632    PdcchCfg rarPdcchCfg;
633    PdschCfg rarPdschCfg;
634 }RarAlloc;
635
636 typedef struct msg4Info
637 {
638    uint16_t crnti;
639    uint8_t  ndi;
640    uint8_t  harqProcNum;
641    uint8_t  dlAssignIdx;
642    uint8_t  pucchTpc;
643    uint8_t  pucchResInd;
644    uint8_t  harqFeedbackInd;
645    uint8_t  dciFormatId;
646    uint8_t  *msg4Pdu;
647    uint16_t  msg4PduLen;
648 }Msg4Info;
649
650 typedef struct msg4Alloc
651 {
652    Msg4Info msg4Info;
653    BwpCfg bwp;
654    PdcchCfg msg4PdcchCfg;
655    PdschCfg msg4PdschCfg;
656 }Msg4Alloc;
657
658 typedef struct schSlotValue
659 {
660    SlotIndInfo currentTime;
661    SlotIndInfo broadcastTime;
662    SlotIndInfo rarTime;
663    SlotIndInfo msg4Time;
664    SlotIndInfo dlMsgTime;
665 }SchSlotValue;
666
667 typedef struct dlSchedInfo
668 {
669    uint16_t cellId;  /* Cell Id */
670    SchSlotValue schSlotValue;
671
672    /* Allocation for broadcast messages */
673    bool isBroadcastPres;
674    DlBrdcstAlloc brdcstAlloc;
675
676    /* Allocation for RAR message */
677    //uint8_t isRarPres;
678    RarAlloc *rarAlloc;
679
680    /* Allocation from MSG4 */
681    Msg4Alloc *msg4Alloc;
682 }DlSchedInfo;
683
684 typedef struct tbInfo
685 {
686    uint8_t  mcs;    /* MCS */
687    uint8_t  ndi;    /* NDI */
688    uint8_t  rv;     /* Redundancy Version */
689    uint16_t tbSize; /* TB Size */
690 }TbInfo;
691
692 typedef struct schPuschInfo
693 {
694    uint8_t          harqProcId;   /* HARQ Process ID */
695    uint8_t          resAllocType; /* Resource allocation type */
696    FreqDomainAlloc  fdAlloc;      /* Freq domain allocation */
697    TimeDomainAlloc  tdAlloc;      /* Time domain allocation */
698    TbInfo           tbInfo;       /* TB info */
699    uint8_t          dmrsMappingType;
700    uint8_t          nrOfDmrsSymbols;
701    uint8_t          dmrsAddPos;
702 }SchPuschInfo;
703
704 typedef struct schPucchInfo
705 {
706    uint16_t         rnti;
707    uint8_t          pucchFormat;
708    FreqDomainAlloc  fdAlloc;      /* Freq domain allocation */
709    TimeDomainAlloc  tdAlloc;      /* Time domain allocation */
710    uint8_t          srFlag;
711    uint8_t          harqFlag;
712    uint8_t          numHarqBits;
713    uint8_t          uciFlag;
714    uint8_t          numUciBits;
715 }SchPucchInfo;
716
717 typedef struct ulSchedInfo
718 {
719    uint16_t      cellId;         /* Cell Id */
720    uint16_t      crnti;          /* CRNI */
721    SlotIndInfo   slotIndInfo;    /* Slot Info: sfn, slot number */
722    uint8_t       dataType;       /* Type of info being scheduled */
723    PrachSchInfo  prachSchInfo;   /* Prach scheduling info */
724    SchPuschInfo  schPuschInfo;   /* Pusch scheduling info */
725    SchPucchInfo  schPucchInfo;   /* Pusch scheduling info */
726 }UlSchedInfo;
727
728 typedef struct rachIndInfo
729 {
730    uint16_t    cellId;
731    uint16_t    crnti;
732    SlotIndInfo timingInfo;
733    uint8_t     slotIdx;
734    uint8_t     symbolIdx;
735    uint8_t     freqIdx;
736    uint8_t     preambleIdx;
737    uint16_t    timingAdv;
738 }RachIndInfo;
739
740
741 typedef struct crcIndInfo
742 {
743    uint16_t    cellId;
744    uint16_t    crnti;
745    SlotIndInfo timingInfo;
746    uint16_t    numCrcInd;
747    uint8_t     crcInd[MAX_NUMBER_OF_CRC_IND_BITS];
748 }CrcIndInfo;
749
750 typedef struct boInfo
751 {
752    uint8_t   lcId;
753    uint32_t  dataVolume;
754 }BOInfo;
755
756 typedef struct dlRlcBOInfo
757 {
758    uint16_t    cellId;
759    uint16_t    crnti;
760    uint16_t    numLc;
761    BOInfo      boInfo[MAX_NUM_LOGICAL_CHANNELS];
762 }DlRlcBOInfo;
763
764 /* Info of Scheduling Request to Add/Modify */
765 typedef struct schSchedReqInfo
766 {
767    uint8_t           schedReqId;
768    SrProhibitTimer   srProhibitTmr;
769    SrTransMax        srTransMax;
770 }SchSchedReqInfo;
771
772 /* Scheduling Request Configuration */
773 typedef struct schSchedReqCfg
774 {
775    uint8_t          addModListCount;
776    SchSchedReqInfo  addModList[MAX_NUM_SR_CFG_PER_CELL_GRP];   /* List of Scheduling req to be added/modified */
777    uint8_t          relListCount;
778    uint8_t          relList[MAX_NUM_SR_CFG_PER_CELL_GRP];      /* list of scheduling request Id to be deleted */
779 }SchSchedReqCfg;
780
781 /* Info of Tag to Add/Modify */
782 typedef struct schTagInfo
783 {
784    uint8_t       tagId;
785    SchTimeAlignmentTimer  timeAlignmentTmr;
786 }SchTagInfo;
787
788 /* Timing Advance Group Configuration */
789 typedef struct schTagCfg
790 {
791    uint8_t      addModListCount;
792    SchTagInfo   addModList[MAX_NUM_TAGS];    /* List of Tag to Add/Modify */
793    uint8_t      relListCount;
794    uint8_t      relList[MAX_NUM_TAGS];       /* list of Tag Id to release */
795 }SchTagCfg;
796
797 /* Configuration for Power headroom reporting */
798 typedef struct schPhrCfg
799 {
800    SchPhrPeriodicTimer       periodicTmr;
801    SchPhrProhibitTimer       prohibitTmr;
802    SchPhrTxPwrFactorChange   txpowerFactorChange;
803    bool                      multiplePhr;
804    bool                      dummy;
805    bool                      type2OtherCell;
806    SchPhrModeOtherCG         modeOtherCG;
807 }SchPhrCfg;
808
809 /* MAC cell Group configuration */
810 typedef struct schMacCellGrpCfg
811 {
812    SchSchedReqCfg   schedReqCfg;
813    SchTagCfg        tagCfg;
814    SchPhrCfg        phrCfg;             /* To be used only if phrCfgSetupPres is true */      
815 }SchMacCellGrpCfg;
816
817 /* Physical Cell Group Configuration */
818 typedef struct schPhyCellGrpCfg
819 {
820    SchPdschHarqAckCodebook    pdschHarqAckCodebook;
821    int8_t     pNrFr1;
822 }SchPhyCellGrpCfg;
823
824 /* Control resource set info */
825 typedef struct schControlRsrcSet
826 {
827    uint8_t             cRSetId;                /* Control resource set id */
828    uint8_t             freqDomainRsrc[FREQ_DOM_RSRC_SIZE];  /* Frequency domain resource */
829    uint8_t             duration;
830    SchREGMappingType   cceRegMappingType;
831    SchPrecoderGranul   precoderGranularity;
832    uint16_t            dmrsScramblingId;
833 }SchControlRsrcSet;
834
835 /* Search Space info */
836 typedef struct schSearchSpace
837 {
838    uint8_t                  searchSpaceId;
839    uint8_t                  cRSetId;
840    SchMSlotPeriodAndOffset  mSlotPeriodicityAndOffset;
841    uint8_t                  mSymbolsWithinSlot[MONITORING_SYMB_WITHIN_SLOT_SIZE];
842    SchAggrLevel             numCandidatesAggLevel1;      /* Number of candidates for aggregation level 1 */
843    SchAggrLevel             numCandidatesAggLevel2;      /* Number of candidates for aggregation level 2 */
844    SchAggrLevel             numCandidatesAggLevel4;      /* Number of candidates for aggregation level 4 */
845    SchAggrLevel             numCandidatesAggLevel8;      /* Number of candidates for aggregation level 8 */
846    SchAggrLevel             numCandidatesAggLevel16;     /* Number of candidates for aggregation level 16 */
847    SchSearchSpaceType       searchSpaceType;
848    uint8_t                  ueSpecificDciFormat;
849 }SchSearchSpace;
850
851 /* PDCCH cofniguration */
852 typedef struct schPdcchConfig
853 {
854    uint8_t           numCRsetToAddMod;
855    SchControlRsrcSet  cRSetToAddModList[MAX_NUM_CRSET];           /* List of control resource set to add/modify */
856    uint8_t           numCRsetToRel;
857    uint8_t           cRSetToRelList[MAX_NUM_CRSET];              /* List of control resource set to release */
858    uint8_t           numSearchSpcToAddMod;
859    SchSearchSpace    searchSpcToAddModList[MAX_NUM_SEARCH_SPC];  /* List of search space to add/modify */
860    uint8_t           numSearchSpcToRel;
861    uint8_t           searchSpcToRelList[MAX_NUM_SEARCH_SPC];     /* List of search space to release */
862 }SchPdcchConfig;
863
864 /* PDSCH time domain resource allocation */
865 typedef struct schPdschTimeDomRsrcAlloc
866 {
867    SchTimeDomRsrcAllocMappingType    mappingType;
868    uint8_t    startSymbol;
869    uint8_t    symbolLength;
870 }SchPdschTimeDomRsrcAlloc;
871
872 /* DMRS downlink configuration */
873 typedef struct schDmrsDlCfg
874 {
875    SchDmrsAdditionPosition   addPos;       /* DMRS additional position */
876 }SchDmrsDlCfg;
877
878 /* PDSCH Configuration */
879 typedef struct schPdschConfig
880 {
881    SchDmrsDlCfg               dmrsDlCfgForPdschMapTypeA;
882    SchResourceAllocType       resourceAllocType;
883    uint8_t                    numTimeDomRsrcAlloc;
884    SchPdschTimeDomRsrcAlloc   timeDomRsrcAllociList[MAX_NUM_DL_ALLOC]; /* PDSCH time domain DL resource allocation list */
885    SchRBGSize                 rbgSize;
886    SchCodeWordsSchedByDci     numCodeWordsSchByDci;                    /* Number of code words scheduled by DCI */
887    SchBundlingType            bundlingType;
888 }SchPdschConfig;
889
890 /* Initial Downlink BWP */
891 typedef struct schInitalDlBwp
892 {
893    bool             pdcchCfgPres;
894    SchPdcchConfig   pdcchCfg;
895    bool             pdschCfgPres;
896    SchPdschConfig   pdschCfg;
897 }SchInitalDlBwp;
898
899 /* BWP Downlink common */
900 typedef struct schBwpDlCommon
901 {
902 }SchBwpDlCommon;
903
904 /* Downlink BWP information */
905 typedef struct schDlBwpInfo
906 {
907    uint8_t          bwpId;
908 }SchDlBwpInfo;
909
910 /* PDCCH Serving Cell configuration */
911 typedef struct schPdschServCellCfg
912 {
913    uint8_t                  *maxMimoLayers;           
914    SchNumHarqProcForPdsch   numHarqProcForPdsch;
915    SchMaxCodeBlkGrpPerTB    *maxCodeBlkGrpPerTb;
916    bool                     *codeBlkGrpFlushInd;
917    SchPdschXOverhead        *xOverhead;
918 }SchPdschServCellCfg;
919
920 /* PUCCH Configuration */
921 typedef struct schPucchCfg
922 {
923    /* TODO : Not used currently */ 
924 }SchPucchCfg;
925
926 /* Transform precoding disabled */
927 typedef struct schTransPrecodDisabled
928 {
929    uint16_t   scramblingId0;
930 }SchTransPrecodDisabled;
931
932 /* DMRS Uplink configuration */
933 typedef struct SchDmrsUlCfg
934 {
935    SchDmrsAdditionPosition    addPos;               /* DMRS additional position */
936    SchTransPrecodDisabled     transPrecodDisabled;  /* Transform precoding disabled */
937 }SchDmrsUlCfg;
938
939 /* PUSCH Time Domain Resource Allocation */
940 typedef struct schPuschTimeDomRsrcAlloc
941 {
942    uint8_t   k2;
943    SchTimeDomRsrcAllocMappingType   mappingType;
944    uint8_t   startSymbol;
945    uint8_t   symbolLength;
946 }SchPuschTimeDomRsrcAlloc;
947
948 /* PUSCH Configuration */
949 typedef struct schPuschCfg
950 {
951    SchDmrsUlCfg               dmrsUlCfgForPuschMapTypeA;
952    SchResourceAllocType       resourceAllocType;
953    uint8_t                    numTimeDomRsrcAlloc;
954    SchPuschTimeDomRsrcAlloc   timeDomRsrcAllocList[MAX_NUM_UL_ALLOC]; /* PUSCH time domain UL resource allocation list */
955    SchTransformPrecoder       transformPrecoder;
956 }SchPuschCfg;
957
958 /* Initial Uplink BWP */
959 typedef struct schInitialUlBwp
960 {
961    bool          pucchCfgPres;
962    SchPucchCfg   pucchCfg;
963    bool          puschCfgPres;
964    SchPuschCfg   puschCfg;
965 }SchInitialUlBwp;
966
967 /* Uplink BWP information */
968 typedef struct schUlBwpInfo
969 {
970    uint8_t        bwpId;
971 }SchUlBwpInfo;
972
973 /* Serving cell configuration */
974 typedef struct schServCellCfgInfo
975 {
976    SchInitalDlBwp        initDlBwp;
977    uint8_t               numDlBwpToAdd;
978    SchDlBwpInfo          DlBwpToAddList[MAX_NUM_BWP];
979    uint8_t               firstActvDlBwpId;
980    uint8_t               defaultDlBwpId;
981    uint8_t               *bwpInactivityTmr;
982    SchPdschServCellCfg   pdschServCellCfg;
983    SchInitialUlBwp       initUlBwp;
984    uint8_t               numUlBwpToAdd;
985    SchUlBwpInfo          UlBwpToAddList[MAX_NUM_BWP];
986    uint8_t               firstActvUlBwpId;
987 }SchServCellCfgInfo;
988
989 typedef struct schNonDynFiveQi
990 {
991    uint16_t   fiveQi;
992    uint8_t    priorLevel;
993    uint16_t   avgWindow;
994    uint16_t   maxDataBurstVol;
995 }SchNonDynFiveQi;
996
997 typedef struct schDynFiveQi
998 {
999    uint8_t    priorLevel;
1000    uint16_t   packetDelayBudget;
1001    uint8_t    packetErrRateScalar;
1002    uint8_t    packetErrRateExp;
1003    uint16_t   fiveQi;
1004    uint8_t    delayCritical;
1005    uint16_t   avgWindow;
1006    uint16_t   maxDataBurstVol;
1007 }SchDynFiveQi;
1008
1009 typedef struct schNgRanAllocAndRetPri
1010 {
1011    uint8_t priorityLevel;
1012    uint8_t preEmptionCap;
1013    uint8_t preEmptionVul;
1014 }SchNgRanAllocAndRetPri;
1015
1016 typedef struct schGrbQosFlowInfo
1017 {
1018    uint32_t maxFlowBitRateDl;
1019    uint32_t maxFlowBitRateUl;
1020    uint32_t guarFlowBitRateDl;
1021    uint32_t guarFlowBitRateUl;
1022 }SchGrbQosFlowInfo;
1023
1024 /* DRB QoS */
1025 typedef struct schDrbQos
1026 {
1027    uint8_t  fiveQiType;   /* Dynamic or non-dynamic */ 
1028    union
1029    {
1030       SchNonDynFiveQi   nonDyn5Qi;
1031       SchDynFiveQi      dyn5Qi;
1032    }u;
1033    SchNgRanAllocAndRetPri  ngRanRetPri;
1034    SchGrbQosFlowInfo       grbQosFlowInfo;
1035    uint16_t                pduSessionId;
1036    uint32_t                ulPduSessAggMaxBitRate;   /* UL PDU Session Aggregate max bit rate */
1037 }SchDrbQosInfo;
1038
1039 typedef struct schSnssai
1040 {
1041    uint8_t   sst;
1042    uint8_t   sd[SD_SIZE];
1043 }SchSnssai;
1044
1045 /* Special cell configuration */
1046 typedef struct schSpCellCfg
1047 {
1048    uint8_t           servCellIdx;
1049    SchServCellCfgInfo   servCellCfg;
1050 }SchSpCellCfg;
1051
1052 /* Uplink logical channel configuration */
1053 typedef struct SchUlLcCfg
1054 {
1055    uint8_t priority;
1056    uint8_t lcGroup;
1057    uint8_t schReqId;
1058    uint8_t pbr;        // prioritisedBitRate
1059    uint8_t bsd;        // bucketSizeDuration
1060 }SchUlLcCfg;
1061
1062 /* Downlink logical channel configuration */
1063 typedef struct schDlLcCfg
1064 {
1065    uint8_t lcp;      // logical Channel Prioritization
1066 }SchDlLcCfg;
1067
1068 /* Logical Channel configuration */
1069 typedef struct schLcCfg
1070 {
1071    uint8_t        lcId;
1072    SchDrbQosInfo  *drbQos;
1073    SchSnssai      *snssai;
1074    SchDlLcCfg     dlLcCfg;
1075    SchUlLcCfg     *ulLcCfg;
1076 }SchLcCfg;
1077
1078 /* Aggregate max bit rate */
1079 typedef struct aggrMaxBitRate
1080 {
1081    uint32_t   ulBitRate;
1082    uint32_t   dlBitRate;
1083 }SchAggrMaxBitRate;
1084
1085 /* UE configuration */
1086 typedef struct schUeCfg
1087 {
1088    uint16_t        cellId;
1089    uint16_t        crnti;
1090    SchMacCellGrpCfg   macCellGrpCfg;
1091    SchPhyCellGrpCfg   phyCellGrpCfg;
1092    SchSpCellCfg       spCellCfg;
1093    SchAggrMaxBitRate  *aggrMaxBitRate;
1094    uint8_t            numLc;
1095    SchLcCfg           lcCfgList[MAX_NUM_LOGICAL_CHANNELS];
1096 }SchUeCfg;
1097
1098 typedef struct schUeCfgRsp
1099 {
1100    uint16_t   ueIdx;
1101    uint16_t   cellId;
1102    uint16_t   crnti;
1103    SchMacRsp  rsp;
1104    SchFailureCause cause;
1105 }SchUeCfgRsp;
1106
1107 /* function pointers */
1108
1109 typedef int (*SchCellCfgCfmFunc)    ARGS((
1110          Pst            *pst,           /* Post Structure */                         
1111          SchCellCfgCfm  *schCellCfgCfm  /* Cell Cfg Cfm */
1112          ));
1113
1114 typedef int (*SchCellCfgFunc)    ARGS((
1115          Pst         *pst,           /* Post Structure */                         
1116          SchCellCfg  *schCellCfg     /* Cell Cfg  */
1117          ));
1118
1119 typedef int (*SchMacDlAllocFunc)     ARGS((                     
1120          Pst            *pst,          /* Post Structure */                         
1121          DlSchedInfo    *dlSchedInfo   /* dl allocation Info */                      
1122          ));
1123
1124 typedef int (*SchMacUlSchInfoFunc)     ARGS((                     
1125          Pst         *pst,           /* Post Structure */                         
1126          UlSchedInfo *ulSchedInfo    /* UL Alloc Sch  Info */                      
1127          ));
1128
1129 typedef int (*MacSchRachIndFunc) ARGS((
1130          Pst         *pst,         /* Post structure */
1131          RachIndInfo *rachInd));    /* Rach Indication Info */
1132
1133 typedef int (*MacSchCrcIndFunc) ARGS(( 
1134          Pst         *pst,         /* Post structure */
1135          CrcIndInfo  *crcInd));     /* CRC Info */
1136
1137 typedef uint8_t (*MacSchDlRlcBoInfoFunc) ARGS((
1138          Pst         *pst,         /* Post structure */
1139          DlRlcBOInfo *dlBoInfo));   /* DL BO Info */
1140
1141 typedef uint8_t (*MacSchUeCreateReqFunc) ARGS((
1142          Pst         *pst,           /* Post structure */
1143          SchUeCfg    *ueCfgToSch));   /* Scheduler UE Cfg */
1144
1145 typedef uint8_t (*SchUeCfgRspFunc) ARGS((
1146          Pst         *pst,           /* Post structure */
1147          SchUeCfgRsp *cfgRsp));       /* Scheduler UE Cfg response */
1148
1149 /* function declarations */
1150 int packMacSchSlotInd(Pst *pst, SlotIndInfo *slotInd);
1151 int packSchMacDlAlloc(Pst *pst, DlSchedInfo  *dlSchedInfo);
1152 int packSchMacUlSchInfo(Pst *pst, UlSchedInfo *ulSchedInfo);
1153 EXTERN int packSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
1154 EXTERN int packSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
1155
1156 EXTERN int MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo);
1157 EXTERN int MacProcSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
1158 EXTERN int MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
1159 EXTERN int SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg);
1160 EXTERN int schActvInit(Ent entity, Inst instId, Region region, Reason reason);
1161 EXTERN S16 SchSendCfgCfm(Pst *pst, RgMngmt *cfm);
1162 EXTERN int MacProcUlSchInfo(Pst *pst, UlSchedInfo *ulSchedInfo);
1163 int packMacSchRachInd(Pst *pst, RachIndInfo *rachInd);
1164 int macSchRachInd(Pst *pst, RachIndInfo *rachInd);
1165 int packMacSchCrcInd(Pst *pst, CrcIndInfo *crcInd);
1166 int macSchCrcInd(Pst *pst, CrcIndInfo *crcInd);
1167 uint8_t packMacSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo);
1168 uint8_t macSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo);
1169 uint8_t packMacSchUeCreateReq(Pst *pst, SchUeCfg *ueCfgToSch);
1170 uint8_t macSchUeCreateReq(Pst *pst, SchUeCfg *ueCfgToSch);
1171 uint8_t packSchUeCfgRsp(Pst *pst, SchUeCfgRsp *cfgRsp);
1172 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *cfgRsp);
1173
1174
1175 /**********************************************************************
1176   End of file
1177  **********************************************************************/
1178