Merge "Encoding of MSG3 UL grant in RAR PDU [Issue-ID: ODUHIGH-342]"
[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_SCH_INFO            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_ADD_UE_CONFIG_REQ_TO_SCH   8
28 #define EVENT_UE_CONFIG_RSP_TO_MAC   9
29 #define EVENT_SLOT_IND_TO_SCH        10
30 #define EVENT_SHORT_BSR              11
31 #define EVENT_UCI_IND_TO_SCH         12
32 #define EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH 13
33 #define EVENT_UE_RECONFIG_RSP_TO_MAC 14
34 #define EVENT_UE_DELETE_REQ_TO_SCH   15
35 #define EVENT_UE_DELETE_RSP_TO_MAC   16
36 #define EVENT_CELL_DELETE_REQ_TO_SCH   17
37 #define EVENT_CELL_DELETE_RSP_TO_MAC   18
38
39
40 /*macros*/
41 #define NO_SSB 0
42 #define SSB_TRANSMISSION 1
43 #define SSB_REPEAT 2
44 #define MAX_SSB_IDX 1 /* forcing it as 1 for now. Right value is 64 */
45 #define SCH_SSB_MASK_SIZE   1
46
47 #define NO_SIB1 0
48 #define SIB1_TRANSMISSION 1
49 #define SIB1_REPITITION 2
50
51 #define MAX_NUM_PRG     1 /* max value should be later 275 */
52 #define MAX_DIG_BF_INTERFACES 0 /* max value should be later 255 */
53 #define MAX_CODEWORDS  1  /* max should be 2 */
54 #define SCH_HARQ_PROC_ID 1 /* harq proc id */
55 #define SCH_ALLOC_TYPE_1 1 /*sch res alloc type */
56
57 /* Datatype in UL SCH Info */
58 #define SCH_DATATYPE_PUSCH 1
59 #define SCH_DATATYPE_PUSCH_UCI 2
60 #define SCH_DATATYPE_UCI 4
61 #define SCH_DATATYPE_SRS 8
62 #define SCH_DATATYPE_PRACH 16
63
64 #define MAX_NUMBER_OF_CRC_IND_BITS 1
65 #define MAX_NUMBER_OF_UCI_IND_BITS 1
66 #define MAX_SR_BITS_IN_BYTES       1
67 #define MAX_NUM_LOGICAL_CHANNEL_GROUPS 8
68 /* can we have a common numslot numscs between mac sch */
69 #ifdef NR_TDD
70 #define MAX_SLOTS 20
71 #else
72 #define MAX_SLOTS 10
73 #endif
74 #define MAX_SFN   1024
75 #define MAX_NUM_SR_CFG_PER_CELL_GRP 8   /* Max number of scheduling request config per cell group */
76 #define MAX_NUM_TAGS 4                  /* Max number of timing advance groups */
77 #define MAX_NUM_BWP  4                  /* Max number of BWP per serving cell */
78 #define MAX_NUM_CRSET  3                /* Max number of control resource set in add/modify/release list */
79 #define MAX_NUM_SEARCH_SPC  10          /* Max number of search space in add/modify/release list */
80 #define FREQ_DOM_RSRC_SIZE  6           /* i.e. 6 bytes because Size of frequency domain resource is 45 bits */
81 #define MONITORING_SYMB_WITHIN_SLOT_SIZE 2  /* i.e. 2 bytes because size of monitoring symbols within slot is 14 bits */
82 #define MAX_NUM_DL_ALLOC 16             /* Max number of pdsch time domain downlink allocation */
83 #define MAX_NUM_UL_ALLOC 16             /* Max number of pusch time domain uplink allocation */
84
85 /* PUCCH Configuration Macro */
86 #define MAX_NUM_PUCCH_RESRC 128
87 #define MAX_NUM_PUCCH_RESRC_SET 4
88 #define MAX_NUM_PUCCH_PER_RESRC_SET 32
89 #define MAX_NUM_SPATIAL_RELATIONS 8
90 #define MAX_NUM_PUCCH_P0_PER_SET 8
91 #define MAX_NUM_PATH_LOSS_REF_RS 4
92 #define MAX_NUM_DL_DATA_TO_UL_ACK 15
93 #define SD_SIZE   3
94
95 #define RAR_PAYLOAD_SIZE 10             /* As per spec 38.321, sections 6.1.5 and 6.2.3, RAR PDU is 8 bytes long and 2 bytes of padding */
96 #define TX_PAYLOAD_HDR_LEN 32           /* Intel L1 requires adding a 32 byte header to transmitted payload */
97
98 #define MAX_NUM_CONFIG_SLOTS 160  /*Max number of slots as per the numerology*/
99 #define MAX_NUM_K0_IDX 16 /* Max number of pdsch time domain downlink allocation */
100 #define MAX_NUM_K1_IDX 8  /* As per spec 38.213 section 9.2.3 Max number of PDSCH-to-HARQ resource indication */
101 #define MIN_NUM_K1_IDX 4  /* Min K1 values */
102 #define MAX_NUM_K2_IDX 16 /* PUSCH time domain UL resource allocation list */
103 #define DEFAULT_K0_VALUE 0 /* As per 38.331, PDSCH-TimeDomainResourceAllocation field descriptions */
104 /* As per 38.331, PUSCH-TimeDomainResourceAllocationList field descriptions */
105 #define DEFAULT_K2_VALUE_FOR_SCS15  1 
106 #define DEFAULT_K2_VALUE_FOR_SCS30  1 
107 #define DEFAULT_K2_VALUE_FOR_SCS60  2
108 #define DEFAULT_K2_VALUE_FOR_SCS120 3 
109
110 #define ADD_DELTA_TO_TIME(crntTime, toFill, incr)          \
111 {                                                          \
112    if ((crntTime.slot + incr) > (MAX_SLOTS - 1))           \
113    {                                                       \
114       toFill.sfn = (crntTime.sfn + 1);                     \
115    }                                                       \
116    else                                                    \
117    {                                                       \
118       toFill.sfn = crntTime.sfn;                           \
119    }                                                       \
120    toFill.slot = (crntTime.slot + incr) % MAX_SLOTS;       \
121    if (toFill.sfn >= MAX_SFN)                              \
122    {                                                       \
123       toFill.sfn%=MAX_SFN;                                 \
124    }                                                       \
125 }
126
127 typedef enum
128 {
129    UNSPECIFIED_CAUSE,
130    INVALID_PARAM_VALUE,
131    RESOURCE_UNAVAILABLE,
132    SYSTEM_ERROR
133 }SchFailureCause;
134
135 typedef enum
136 {
137    SR_PROHIBIT_MS1,
138    SR_PROHIBIT_MS2,
139    SR_PROHIBIT_MS4,
140    SR_PROHIBIT_MS8,
141    SR_PROHIBIT_MS16,
142    SR_PROHIBIT_MS32,
143    SR_PROHIBIT_MS64,
144    SR_PROHIBIT_MS128
145 }SchSrProhibitTimer;
146
147 typedef enum
148 {
149    NOT_APPLICABLE,
150    INVALID_CELLID,
151    INVALID_UEIDX
152 }ErrorCause;
153
154 typedef enum
155 {
156    SR_TRANS_MAX_N4,
157    SR_TRANS_MAX_N8,
158    SR_TRANS_MAX_N16,
159    SR_TRANS_MAX_N32,
160    SR_TRANS_MAX_N64,
161    SR_TRANS_MAX_SPARE3,
162    SR_TRANS_MAX_SPARE2,
163    SR_TRANS_MAX_SPARE1
164 }SchSrTransMax;
165
166 typedef enum
167 {
168    TIME_ALIGNMENT_TIMER_MS500,
169    TIME_ALIGNMENT_TIMER_MS750,
170    TIME_ALIGNMENT_TIMER_MS1280,
171    TIME_ALIGNMENT_TIMER_MS1920,
172    TIME_ALIGNMENT_TIMER_MS2560,
173    TIME_ALIGNMENT_TIMER_MS5120,
174    TIME_ALIGNMENT_TIMER_MS10240,
175    TIME_ALIGNMENT_TIMER_INFINITE
176 }SchTimeAlignmentTimer;
177
178 typedef enum
179 {
180    PHR_PERIODIC_TIMER_SF10,
181    PHR_PERIODIC_TIMER_SF20,
182    PHR_PERIODIC_TIMER_SF50,
183    PHR_PERIODIC_TIMER_SF100,
184    PHR_PERIODIC_TIMER_SF200,
185    PHR_PERIODIC_TIMER_SF500,
186    PHR_PERIODIC_TIMER_SF1000,
187    PHR_PERIODIC_TIMER_INFINITE
188 }SchPhrPeriodicTimer;
189
190 typedef enum
191 {
192    PHR_PROHIBIT_TIMER_SF0,
193    PHR_PROHIBIT_TIMER_SF10,
194    PHR_PROHIBIT_TIMER_SF20,
195    PHR_PROHIBIT_TIMER_SF50,
196    PHR_PROHIBIT_TIMER_SF100,
197    PHR_PROHIBIT_TIMER_SF200,
198    PHR_PROHIBIT_TIMER_SF500,
199    PHR_PROHIBIT_TIMER_SF1000
200 }SchPhrProhibitTimer;
201
202 typedef enum
203 {
204    PHR_TX_PWR_FACTOR_CHANGE_DB1,
205    PHR_TX_PWR_FACTOR_CHANGE_DB3,
206    PHR_TX_PWR_FACTOR_CHANGE_DB6,
207    PHR_TX_PWR_FACTOR_CHANGE_INFINITE
208 }SchPhrTxPwrFactorChange;
209
210 typedef enum
211 {
212    PHR_MODE_REAL,
213    PHR_MODE_VIRTUAL
214 }SchPhrModeOtherCG;
215
216 typedef enum
217 {
218    HARQ_ACK_CODEBOOK_SEMISTATIC,
219    HARQ_ACK_CODEBOOK_DYNAMIC
220 }SchPdschHarqAckCodebook;
221
222 typedef enum
223 {
224    NUM_HARQ_PROC_FOR_PDSCH_N2,
225    NUM_HARQ_PROC_FOR_PDSCH_N4,
226    NUM_HARQ_PROC_FOR_PDSCH_N6,
227    NUM_HARQ_PROC_FOR_PDSCH_N10,
228    NUM_HARQ_PROC_FOR_PDSCH_N16
229 }SchNumHarqProcForPdsch;
230
231 typedef enum
232 {
233    MAX_CODE_BLOCK_GROUP_PER_TB_N2,
234    MAX_CODE_BLOCK_GROUP_PER_TB_N4,
235    MAX_CODE_BLOCK_GROUP_PER_TB_N6,
236    MAX_CODE_BLOCK_GROUP_PER_TB_N8
237 }SchMaxCodeBlkGrpPerTB;
238
239 typedef enum
240 {
241    PDSCH_X_OVERHEAD_XOH_6,
242    PDSCH_X_OVERHEAD_XOH_12,
243    PDSCH_X_OVERHEAD_XOH_18
244 }SchPdschXOverhead;
245
246 typedef enum
247 {
248    DMRS_ADDITIONAL_POS0,
249    DMRS_ADDITIONAL_POS1,
250    DMRS_ADDITIONAL_POS3
251 }SchDmrsAdditionPosition;
252
253 typedef enum
254 {
255    RESOURCE_ALLOCTION_TYPE_0,
256    RESOURCE_ALLOCTION_TYPE_1,
257    RESOURCE_ALLOCTION_DYN_SWITCH
258 }SchResourceAllocType;
259
260 typedef enum
261 {
262    TIME_DOMAIN_RSRC_ALLOC_MAPPING_TYPE_A,
263    TIME_DOMAIN_RSRC_ALLOC_MAPPING_TYPE_B
264 }SchTimeDomRsrcAllocMappingType;
265
266 typedef enum
267 {
268    ENABLED_TRANSFORM_PRECODER,
269    DISABLED_TRANSFORM_PRECODER
270 }SchTransformPrecoder;
271
272 typedef enum
273 {
274    INTERLEAVED_CCE_REG_MAPPING = 1,
275    NONINTERLEAVED_CCE_REG_MAPPING
276 }SchREGMappingType;
277
278 typedef enum
279 {
280    SLOT_PERIODICITY_AND_OFFSET_SL_1 = 1,
281    SLOT_PERIODICITY_AND_OFFSET_SL_2,
282    SLOT_PERIODICITY_AND_OFFSET_SL_4,
283    SLOT_PERIODICITY_AND_OFFSET_SL_5,
284    SLOT_PERIODICITY_AND_OFFSET_SL_8,
285    SLOT_PERIODICITY_AND_OFFSET_SL_10,
286    SLOT_PERIODICITY_AND_OFFSET_SL_16,
287    SLOT_PERIODICITY_AND_OFFSET_SL_20,
288    SLOT_PERIODICITY_AND_OFFSET_SL_40,
289    SLOT_PERIODICITY_AND_OFFSET_SL_80,
290    SLOT_PERIODICITY_AND_OFFSET_SL_160,
291    SLOT_PERIODICITY_AND_OFFSET_SL_320,
292    SLOT_PERIODICITY_AND_OFFSET_SL_640,
293    SLOT_PERIODICITY_AND_OFFSET_SL_1280,
294    SLOT_PERIODICITY_AND_OFFSET_SL_2560
295 }SchMSlotPeriodAndOffset;
296
297 typedef enum
298 {
299    SAME_AS_REG_BUNDLE,
300    ALL_CONTIGUOUS_RB
301 }SchPrecoderGranul;
302
303 typedef enum
304 {
305    SEARCH_SPACE_TYPE_COMMON = 1,
306    SEARCH_SPACE_TYPE_UE_SPECIFIC
307 }SchSearchSpaceType;
308
309 typedef enum
310 {
311    SCH_QOS_NON_DYNAMIC = 1,
312    SCH_QOS_DYNAMIC
313 }SchQosType;
314
315 typedef enum
316 {
317    AGGREGATION_LEVEL_N0,
318    AGGREGATION_LEVEL_N1,
319    AGGREGATION_LEVEL_N2,
320    AGGREGATION_LEVEL_N3,
321    AGGREGATION_LEVEL_N4,
322    AGGREGATION_LEVEL_N5,
323    AGGREGATION_LEVEL_N6,
324    AGGREGATION_LEVEL_N8
325 }SchAggrLevel;
326
327 typedef enum
328 {
329    RBG_SIZE_CONFIG_1,
330    RBG_SIZE_CONFIG_2
331 }SchRBGSize;
332
333 typedef enum
334 {
335    CODE_WORDS_SCHED_BY_DCI_N1,
336    CODE_WORDS_SCHED_BY_DCI_N2
337 }SchCodeWordsSchedByDci;
338
339 typedef enum
340 {
341    STATIC_BUNDLING_TYPE = 1,
342    DYNAMIC_BUNDLING_TYPE
343 }SchBundlingType;
344
345 typedef enum
346 {
347    SCH_SET1_SIZE_N4,
348    SCH_SET1_SIZE_WIDEBAND,
349    SCH_SET1_SIZE_N2_WIDEBAND,
350    SCH_SET1_SIZE_N4_WIDEBAND
351 }SchBundlingSizeSet1;
352
353 typedef enum
354 {
355    SCH_SET2_SIZE_N4,
356    SCH_SET2_SIZE_WIDEBAND
357 }SchBundlingSizeSet2;
358
359 typedef enum
360 {
361    DUPLEX_MODE_FDD,
362    DUPLEX_MODE_TDD
363 }SchDuplexMode;
364
365 typedef enum
366 {
367    SSB_PRDCTY_MS5,
368    SSB_PRDCTY_MS10,
369    SSB_PRDCTY_MS20,
370    SSB_PRDCTY_MS40,
371    SSB_PRDCTY_MS80,
372    SSB_PRDCTY_MS160
373 }SchSSBPeriod;
374
375 typedef enum
376 {
377    RSP_OK,
378    RSP_NOK
379 }SchMacRsp;
380
381 typedef enum
382 {
383    SHORT_BSR,
384    LONG_BSR,
385    SHORT_TRUNCATED_BSR,
386    LONG_TRUNCATED_BSR
387 }BsrType;
388
389 typedef enum
390 {
391    FORMAT0_0,
392    FORMAT0_1,
393    FORMAT1_0,
394    FORMAT1_1
395 }FormatType;
396
397 typedef enum
398 {
399    SCH_MCS_TABLE_QAM_64,
400    SCH_MCS_TABLE_QAM_256,
401    SCH_MCS_TABLE_QAM_64_LOW_SE
402 }SchMcsTable;
403
404 /*structures*/
405 typedef struct timeDomainAlloc
406 {
407    uint16_t startSymb;
408    uint16_t numSymb;
409 }TimeDomainAlloc;
410
411 typedef struct freqDomainAlloc
412 {
413    uint16_t startPrb;
414    uint16_t numPrb;
415 }FreqDomainAlloc;
416
417
418 typedef struct
419 {
420    uint32_t    ssbPbchPwr;       /* SSB block power */
421    uint8_t     scsCommon;           /* subcarrier spacing for common [0-3]*/
422    uint8_t     ssbOffsetPointA;  /* SSB sub carrier offset from point A */
423    SchSSBPeriod   ssbPeriod;        /* SSB Periodicity in msec */
424    uint8_t     ssbSubcOffset;    /* Subcarrier Offset(Kssb) */
425    uint32_t    nSSBMask[SCH_SSB_MASK_SIZE];      /* Bitmap for actually transmitted SSB. */
426 }SchSsbCfg;
427
428 typedef struct bwpCfg
429 {
430    uint8_t         subcarrierSpacing;
431    uint8_t         cyclicPrefix;
432    FreqDomainAlloc freqAlloc;   
433 }BwpCfg;
434
435 typedef struct prg
436 {
437    uint16_t pmIdx;
438    uint16_t beamIdx[MAX_DIG_BF_INTERFACES];
439 } Prg;
440
441 typedef struct beamformingInfo
442 {
443    uint16_t numPrgs;
444    uint16_t prgSize;
445    uint8_t  digBfInterfaces;
446    Prg  prg[MAX_NUM_PRG];
447 } BeamformingInfo;
448
449 /* SIB1 PDSCH structures */
450
451 typedef struct codewordinfo
452 {
453    uint16_t targetCodeRate;
454    uint8_t  qamModOrder;
455    uint8_t  mcsIndex;
456    uint8_t  mcsTable;
457    uint8_t  rvIndex;
458    uint32_t tbSize;
459 } CodewordInfo;
460
461 typedef struct dmrsInfo
462 {
463    uint16_t dlDmrsSymbPos;
464    uint8_t  dmrsConfigType;
465    uint16_t dlDmrsScramblingId;
466    uint8_t  scid;
467    uint8_t  numDmrsCdmGrpsNoData;
468    uint16_t dmrsPorts;
469    uint8_t mappingType;
470    uint8_t nrOfDmrsSymbols;
471    uint8_t dmrsAddPos;
472 } DmrsInfo;
473
474 typedef struct pdschFreqAlloc
475 {
476    uint8_t  resourceAllocType;
477    /* since we are using type-1, rbBitmap excluded */
478    FreqDomainAlloc freqAlloc;
479    uint8_t  vrbPrbMapping;
480 } PdschFreqAlloc;
481
482 typedef struct pdschTimeAlloc
483 {
484    uint8_t         rowIndex;
485    TimeDomainAlloc timeAlloc;
486 } PdschTimeAlloc;
487
488 typedef struct txPowerPdschInfo
489 {
490    uint8_t powerControlOffset;
491    uint8_t powerControlOffsetSS;
492 } TxPowerPdschInfo;
493
494 typedef struct pdschCfg
495 {
496    uint16_t         pduBitmap;
497    uint16_t         rnti;
498    uint16_t         pduIndex;
499    uint8_t          numCodewords;
500    CodewordInfo     codeword[MAX_CODEWORDS];
501    uint16_t         dataScramblingId;
502    uint8_t          numLayers;
503    uint8_t          transmissionScheme;
504    uint8_t          refPoint;
505    DmrsInfo         dmrs;
506    PdschFreqAlloc   pdschFreqAlloc;
507    PdschTimeAlloc   pdschTimeAlloc;
508    BeamformingInfo  beamPdschInfo;
509    TxPowerPdschInfo txPdschPower;
510 } PdschCfg;
511 /* SIB1 PDSCH structures end */
512
513 /* SIB1 interface structure */
514
515 typedef struct coresetCfg
516 {
517    uint8_t coreSetSize;
518    uint8_t startSymbolIndex;
519    uint8_t durationSymbols;
520    uint8_t freqDomainResource[6];
521    uint8_t cceRegMappingType;
522    uint8_t regBundleSize;
523    uint8_t interleaverSize;
524    uint8_t coreSetType;
525    uint16_t shiftIndex;
526    uint8_t precoderGranularity;
527    uint8_t cceIndex;
528    uint8_t aggregationLevel;
529 } CoresetCfg;
530
531 typedef struct txPowerPdcchInfo
532 {
533    uint8_t powerValue;
534    uint8_t powerControlOffsetSS;
535 } TxPowerPdcchInfo;
536
537 typedef struct dlDCI
538 {
539    uint16_t rnti;
540    uint16_t scramblingId;
541    uint16_t scramblingRnti;
542    uint8_t cceIndex;
543    uint8_t aggregLevel;
544    BeamformingInfo beamPdcchInfo;
545    TxPowerPdcchInfo txPdcchPower;
546    PdschCfg     *pdschCfg;
547 } DlDCI;
548
549 typedef struct pdcchCfg
550 {
551    /* coreset-0 configuration */
552    CoresetCfg coresetCfg;
553
554    uint16_t numDlDci;
555    DlDCI    dci; /* as of now its only one DCI, later it will be numDlCi */
556 } PdcchCfg;
557 /* end of SIB1 PDCCH structures */
558
559 typedef struct
560 {
561    /* parameters recieved from DU-APP */
562    uint16_t sib1PduLen;
563    uint16_t sib1RepetitionPeriod;
564    uint8_t  coresetZeroIndex;     /* derived from 4 LSB of pdcchSib1 present in MIB */
565    uint8_t  searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */
566    uint16_t sib1Mcs;
567
568    /* parameters derived in scheduler */
569    uint8_t n0;
570    BwpCfg bwp;
571    PdcchCfg sib1PdcchCfg;
572    PdschCfg sib1PdschCfg;
573 }SchSib1Cfg;
574
575 typedef struct schRachCfg
576 {
577    uint8_t      prachCfgIdx;       /* PRACH config idx */
578    uint8_t      prachSubcSpacing;  /* Subcarrier spacing of RACH */
579    uint16_t     msg1FreqStart;     /* Msg1-FrequencyStart */
580    uint8_t      msg1Fdm;           /* PRACH FDM (1,2,4,8) */
581    uint8_t      rootSeqLen;        /* root sequence length */
582    uint16_t     rootSeqIdx;        /* Root sequence index */
583    uint8_t      numRootSeq;        /* Number of root sequences required for FD */
584    uint16_t     k1;                /* Frequency Offset for each FD */
585    uint8_t      ssbPerRach;        /* SSB per RACH occassion */
586    uint8_t      prachMultCarrBand; /* Presence of Multiple carriers in Band */
587    uint8_t      raContResTmr;      /* RA Contention Resoultion Timer */
588    uint8_t      rsrpThreshSsb;     /* RSRP Threshold SSB */
589    uint8_t      raRspWindow;       /* RA Response Window */
590 }SchRachCfg;
591
592 typedef struct schBwpParams
593 {
594    FreqDomainAlloc freqAlloc;
595    uint8_t         scs;
596    uint8_t         cyclicPrefix;
597 }SchBwpParams;
598
599 typedef struct schCandidatesInfo
600 {
601    uint8_t aggLevel1;
602    uint8_t aggLevel2;
603    uint8_t aggLevel4;
604    uint8_t aggLevel8;
605    uint8_t aggLevel16;
606 }SchCandidatesInfo;
607
608 typedef struct schSearchSpaceCfg
609 {
610    uint8_t searchSpaceId;
611    uint8_t coresetId;
612    uint16_t monitoringSlot;
613    uint16_t duration;
614    uint16_t monitoringSymbol;
615    SchCandidatesInfo candidate;
616 }SchSearchSpaceCfg;
617
618 typedef struct schPdcchCfgCmn
619 {
620    SchSearchSpaceCfg commonSearchSpace;
621    uint8_t raSearchSpaceId;
622 }SchPdcchCfgCmn;
623
624 typedef struct schPdschCfgCmnTimeDomRsrcAlloc
625 {
626    uint8_t k0;
627    uint8_t mappingType;
628    uint8_t startSymbol;
629    uint8_t lengthSymbol;
630 }SchPdschCfgCmnTimeDomRsrcAlloc;
631
632 typedef struct schPdschCfgCmn
633 {
634    uint8_t   numTimeDomAlloc;
635    SchPdschCfgCmnTimeDomRsrcAlloc timeDomRsrcAllocList[MAX_NUM_DL_ALLOC];
636 }SchPdschCfgCmn;
637
638 typedef struct schPucchCfgCmn
639 {
640    uint8_t pucchResourceCommon;
641    uint8_t pucchGroupHopping;
642 }SchPucchCfgCmn;
643
644 /* PUSCH Time Domain Resource Allocation */
645 typedef struct schPuschTimeDomRsrcAlloc
646 {
647    uint8_t   k2;
648    SchTimeDomRsrcAllocMappingType   mappingType;
649    uint8_t   startSymbol;
650    uint8_t   symbolLength;
651 }SchPuschTimeDomRsrcAlloc;
652
653 typedef struct schPuschCfgCmn
654 {
655    uint8_t                    numTimeDomRsrcAlloc;
656    SchPuschTimeDomRsrcAlloc   timeDomRsrcAllocList[MAX_NUM_UL_ALLOC]; /* PUSCH time domain UL resource allocation list */
657 }SchPuschCfgCmn;
658
659 typedef struct schK1TimingInfo
660 {
661    uint8_t numK1;
662    uint8_t k1Indexes[MAX_NUM_K1_IDX];
663 }SchK1TimingInfo;
664
665 typedef struct schK0TimingInfo
666 {
667    uint8_t k0Index;
668    SchK1TimingInfo k1TimingInfo;
669 }SchK0TimingInfo;
670
671 typedef struct schK0K1TimingInfo
672 {
673    uint8_t numK0;
674    SchK0TimingInfo k0Indexes[MAX_NUM_K0_IDX];
675 }SchK0K1TimingInfo;
676
677 typedef struct schK0K1TimingInfoTbl
678 {
679    uint16_t tblSize;
680    SchK0K1TimingInfo k0k1TimingInfo[MAX_NUM_CONFIG_SLOTS];
681 }SchK0K1TimingInfoTbl;
682
683 typedef struct schBwpDlCfg
684 {
685    SchBwpParams   bwp;
686    SchPdcchCfgCmn pdcchCommon;
687    SchPdschCfgCmn pdschCommon;
688    SchK0K1TimingInfoTbl k0K1InfoTbl;
689 }SchBwpDlCfg;
690
691 typedef struct schK2TimingInfo
692 {
693    uint8_t numK2; 
694    uint8_t k2Indexes[MAX_NUM_K2_IDX]; 
695 }SchK2TimingInfo;
696
697 typedef struct schK2TimingInfoTbl
698 {
699    uint16_t tblSize; 
700    SchK2TimingInfo k2TimingInfo[MAX_NUM_CONFIG_SLOTS]; 
701 }SchK2TimingInfoTbl;
702
703 typedef struct schBwpUlCfg
704 {
705    SchBwpParams   bwp;
706    SchPucchCfgCmn pucchCommon;
707    SchPuschCfgCmn puschCommon;
708    SchK2TimingInfoTbl k2InfoTbl;
709 }SchBwpUlCfg;
710
711 typedef struct schCellCfg
712 {
713    uint16_t       cellId;           /* Cell Id */
714    uint16_t       phyCellId;        /* Physical cell id */
715    uint8_t        numerology;       /* Supported numerology */
716    SchDuplexMode  dupMode;          /* Duplex type: TDD/FDD */
717    uint8_t        bandwidth;        /* Supported B/W */
718    uint32_t       dlFreq;           /* DL Frequency */
719    uint32_t       ulFreq;           /* UL Frequency */
720    SchSsbCfg      ssbSchCfg;        /* SSB config */
721    SchSib1Cfg     sib1SchCfg;       /* SIB1 config */
722    SchRachCfg     schRachCfg;       /* PRACH config */
723    SchBwpDlCfg    schInitialDlBwp;  /* Initial DL BWP */
724    SchBwpUlCfg    schInitialUlBwp;  /* Initial UL BWP */
725 #ifdef NR_TDD
726    TDDCfg         tddCfg;           /* TDD Cfg */ 
727 #endif
728 }SchCellCfg;
729
730 typedef struct schCellCfgCfm
731 {
732    uint16_t         cellId;     /* Cell Id */
733    SchMacRsp   rsp;   
734 }SchCellCfgCfm;
735
736 typedef struct ssbInfo
737 {
738    uint8_t         ssbIdx;          /* SSB Index */
739    TimeDomainAlloc tdAlloc; /* Time domain allocation */
740    FreqDomainAlloc fdAlloc; /* Freq domain allocation */
741 }SsbInfo;
742
743 typedef struct sib1AllocInfo
744 {
745    BwpCfg bwp;
746    PdcchCfg sib1PdcchCfg;
747    PdschCfg sib1PdschCfg;
748 } Sib1AllocInfo;
749
750 typedef struct prachSchInfo
751 {
752    uint8_t  numPrachOcas;   /* Num Prach Ocassions */
753    uint8_t  prachFormat;    /* PRACH Format */
754    uint8_t  numRa;          /* Freq domain ocassion */
755    uint8_t  prachStartSymb; /* Freq domain ocassion */
756 }PrachSchInfo;
757
758 /* Interface structure signifying DL broadcast allocation for SSB, SIB1 */
759 typedef struct dlBrdcstAlloc
760 {
761    /* Ssb transmission is determined as follows:
762     * 0 : No tranamission
763     * 1 : SSB Transmission
764     * 2 : SSB Repetition */
765    uint8_t ssbTrans;
766    uint8_t ssbIdxSupported;
767    SsbInfo ssbInfo[MAX_SSB_IDX];
768    /* Sib1 transmission is determined as follows:
769     * 0 : No tranamission
770     * 1 : SIB1 Transmission
771     * 2 : SIB1 Repetition */
772    uint8_t sib1Trans;
773    Sib1AllocInfo sib1Alloc;
774 }DlBrdcstAlloc;
775
776 typedef struct msg3UlGrant
777 {
778    uint8_t         freqHopFlag;
779    uint16_t        bwpSize;
780    FreqDomainAlloc msg3FreqAlloc;
781    uint8_t         k2Index;
782    uint8_t         mcs;
783    uint8_t         tpc;
784    uint8_t         csiReq;
785 }Msg3UlGrant;
786
787 typedef struct rarInfo
788 {
789    uint16_t        raRnti;
790    uint8_t         RAPID;
791    uint16_t        ta;
792    Msg3UlGrant     ulGrant;
793    uint16_t        tcrnti;
794    uint8_t         rarPdu[RAR_PAYLOAD_SIZE];
795    uint8_t         rarPduLen;
796 }RarInfo;
797
798 typedef struct rarAlloc
799 {
800    RarInfo rarInfo;
801    BwpCfg  bwp;
802    PdcchCfg rarPdcchCfg;
803    PdschCfg rarPdschCfg;
804 }RarAlloc;
805
806 typedef struct dlMsgInfo
807 {
808    uint16_t crnti;
809    uint8_t  ndi;
810    uint8_t  harqProcNum;
811    uint8_t  dlAssignIdx;
812    uint8_t  pucchTpc;
813    uint8_t  pucchResInd;
814    uint8_t  harqFeedbackInd;
815    uint8_t  dciFormatId;
816    bool     isMsg4Pdu;
817    uint16_t  dlMsgPduLen;
818    uint8_t  *dlMsgPdu;
819 }DlMsgInfo;
820
821 typedef struct lcSchInfo
822 {
823    uint8_t   lcId;
824    uint32_t  schBytes; /* Number of scheduled bytes */
825 }LcSchInfo;
826
827 typedef struct dlMsgAlloc
828 {
829    uint16_t   crnti;
830    uint8_t    numLc;
831    LcSchInfo  lcSchInfo[MAX_NUM_LC]; /* Scheduled LC info */
832    BwpCfg     bwp;
833    PdcchCfg   dlMsgPdcchCfg;
834    PdschCfg   dlMsgPdschCfg;
835    DlMsgInfo  dlMsgInfo;
836 }DlMsgAlloc;
837
838 typedef struct schSlotValue
839 {
840    SlotTimingInfo currentTime;
841    SlotTimingInfo broadcastTime;
842    SlotTimingInfo rarTime;
843    SlotTimingInfo dlMsgTime;
844    SlotTimingInfo ulDciTime;
845 }SchSlotValue;
846
847 typedef struct format0_0
848 {
849    uint8_t         resourceAllocType;
850    /* since we are using type-1, hence rbBitmap excluded */
851    FreqDomainAlloc freqAlloc;
852    TimeDomainAlloc timeAlloc;
853    uint16_t        rowIndex;
854    uint8_t         mcs;
855    uint8_t         harqProcId;   /* HARQ Process ID */
856    bool            puschHopFlag;
857    bool            freqHopFlag;
858    uint8_t         ndi;    /* NDI */
859    uint8_t         rv;     /* Redundancy Version */
860    uint8_t         tpcCmd;
861    bool            sUlCfgd;
862 }Format0_0;
863
864 typedef struct format0_1
865 {
866 /* TBD */
867
868 }Format0_1;
869
870 typedef struct format1_0
871 {
872 /* TBD */
873
874 }Format1_0;
875
876 typedef struct format1_1
877 {
878 /* TBD */
879 }Format1_1;
880
881 typedef struct dciInfo
882 {
883    uint16_t      cellId;   
884    uint16_t      crnti;          /* CRNI */
885    SlotTimingInfo   slotIndInfo;    /* Slot Info: sfn, slot number */
886    BwpCfg        bwpCfg;         /* BWP Cfg */
887    CoresetCfg    coresetCfg;     /* Coreset1 Cfg */
888    FormatType    formatType;     /* DCI Format */
889    union
890    {
891       Format0_0  format0_0;      /* Format 0_0 */
892       Format0_1  format0_1;      /* Format 0_1 */
893       Format1_0  format1_0;      /* Format 1_0 */
894       Format1_1  format1_1;      /* Format 1_1 */
895    }format;
896    DlDCI    dciInfo;
897 }DciInfo;
898
899
900 typedef struct dlSchedInfo
901 {
902    uint16_t cellId;  /* Cell Id */
903    SchSlotValue schSlotValue;
904
905    /* Allocation for broadcast messages */
906    bool isBroadcastPres;
907    DlBrdcstAlloc brdcstAlloc;
908
909    /* Allocation for RAR message */
910    //uint8_t isRarPres;
911    RarAlloc *rarAlloc;
912
913    /* Allocation from MSG4 */
914    //Msg4Alloc *msg4Alloc;
915
916    /* UL grant in response to BSR */
917    DciInfo    *ulGrant;
918
919    /* Allocation from dedicated DL msg */
920    DlMsgAlloc *dlMsgAlloc;
921
922 }DlSchedInfo;
923
924 typedef struct tbInfo
925 {
926    uint8_t  qamOrder;  /* Modulation Order */
927    uint8_t  mcs;       /* MCS */
928    SchMcsTable  mcsTable;  /* MCS Table */
929    uint8_t  ndi;       /* NDI */
930    uint8_t  rv;        /* Redundancy Version */
931    uint16_t tbSize;    /* TB Size */
932 }TbInfo;
933
934 typedef struct schPuschInfo
935 {
936    uint16_t         crnti;
937    uint8_t          harqProcId;   /* HARQ Process ID */
938    uint8_t          resAllocType; /* Resource allocation type */
939    FreqDomainAlloc  fdAlloc;      /* Freq domain allocation */
940    TimeDomainAlloc  tdAlloc;      /* Time domain allocation */
941    TbInfo           tbInfo;       /* TB info */
942    uint8_t          dmrsMappingType;
943    uint8_t          nrOfDmrsSymbols;
944    uint8_t          dmrsAddPos;
945 }SchPuschInfo;
946
947 typedef struct schPucchFormatCfg
948 {
949    uint8_t interSlotFreqHop;
950    uint8_t addDmrs;
951    uint8_t maxCodeRate;
952    uint8_t numSlots;
953    bool    pi2BPSK;
954    bool    harqAckCSI;
955 }SchPucchFormatCfg;
956
957 typedef struct schPucchInfo
958 {
959    uint16_t         rnti;
960    uint8_t          pucchFormat;
961    FreqDomainAlloc  fdAlloc;      /* Freq domain allocation */
962    TimeDomainAlloc  tdAlloc;      /* Time domain allocation */
963    uint8_t          srFlag;
964    uint8_t          harqFlag;
965    uint8_t          numHarqBits;
966    uint8_t          uciFlag;
967    uint8_t          numUciBits;
968    uint8_t          intraFreqHop;
969    uint16_t         secondPrbHop;
970    uint8_t          initialCyclicShift;
971    uint8_t          occLen;
972    uint8_t          occIdx;
973    uint8_t          timeDomOCC;
974    SchPucchFormatCfg cmnFormatCfg;
975 }SchPucchInfo;
976
977 typedef struct ulSchedInfo
978 {
979    uint16_t      cellId;         /* Cell Id */
980    uint16_t      crnti;          /* CRNI */
981    SlotTimingInfo   slotIndInfo;    /* Slot Info: sfn, slot number */
982    uint8_t       dataType;       /* Type of info being scheduled */
983    PrachSchInfo  prachSchInfo;   /* Prach scheduling info */
984    SchPuschInfo  schPuschInfo;   /* Pusch scheduling info */
985    SchPucchInfo  schPucchInfo;   /* Pusch scheduling info */
986 }UlSchedInfo;
987
988 typedef struct rachIndInfo
989 {
990    uint16_t    cellId;
991    uint16_t    crnti;
992    SlotTimingInfo timingInfo;
993    uint8_t     slotIdx;
994    uint8_t     symbolIdx;
995    uint8_t     freqIdx;
996    uint8_t     preambleIdx;
997    uint16_t    timingAdv;
998 }RachIndInfo;
999
1000
1001 typedef struct crcIndInfo
1002 {
1003    uint16_t    cellId;
1004    uint16_t    crnti;
1005    SlotTimingInfo timingInfo;
1006    uint16_t    numCrcInd;
1007    uint8_t     crcInd[MAX_NUMBER_OF_CRC_IND_BITS];
1008 }CrcIndInfo;
1009
1010 typedef struct boInfo
1011 {
1012    uint8_t   lcId;
1013    uint32_t  dataVolume;
1014 }BOInfo;
1015
1016 typedef struct dlRlcBOInfo
1017 {
1018    uint16_t    cellId;
1019    uint16_t    crnti;
1020    uint8_t     lcId;
1021    uint32_t    dataVolume;
1022 }DlRlcBoInfo;
1023
1024 /* Info of Scheduling Request to Add/Modify */
1025 typedef struct schSchedReqInfo
1026 {
1027    uint8_t              schedReqId;
1028    SchSrProhibitTimer   srProhibitTmr;
1029    SchSrTransMax        srTransMax;
1030 }SchSchedReqInfo;
1031
1032 /* Scheduling Request Configuration */
1033 typedef struct schSchedReqCfg
1034 {
1035    uint8_t          addModListCount;
1036    SchSchedReqInfo  addModList[MAX_NUM_SR_CFG_PER_CELL_GRP];   /* List of Scheduling req to be added/modified */
1037    uint8_t          relListCount;
1038    uint8_t          relList[MAX_NUM_SR_CFG_PER_CELL_GRP];      /* list of scheduling request Id to be deleted */
1039 }SchSchedReqCfg;
1040
1041 /* Info of Tag to Add/Modify */
1042 typedef struct schTagInfo
1043 {
1044    uint8_t       tagId;
1045    SchTimeAlignmentTimer  timeAlignmentTmr;
1046 }SchTagInfo;
1047
1048 /* Timing Advance Group Configuration */
1049 typedef struct schTagCfg
1050 {
1051    uint8_t      addModListCount;
1052    SchTagInfo   addModList[MAX_NUM_TAGS];    /* List of Tag to Add/Modify */
1053    uint8_t      relListCount;
1054    uint8_t      relList[MAX_NUM_TAGS];       /* list of Tag Id to release */
1055 }SchTagCfg;
1056
1057 /* Configuration for Power headroom reporting */
1058 typedef struct schPhrCfg
1059 {
1060    SchPhrPeriodicTimer       periodicTmr;
1061    SchPhrProhibitTimer       prohibitTmr;
1062    SchPhrTxPwrFactorChange   txpowerFactorChange;
1063    bool                      multiplePhr;
1064    bool                      dummy;
1065    bool                      type2OtherCell;
1066    SchPhrModeOtherCG         modeOtherCG;
1067 }SchPhrCfg;
1068
1069 /* MAC cell Group configuration */
1070 typedef struct schMacCellGrpCfg
1071 {
1072    SchSchedReqCfg   schedReqCfg;
1073    SchTagCfg        tagCfg;
1074    SchPhrCfg        phrCfg;             /* To be used only if phrCfgSetupPres is true */      
1075 }SchMacCellGrpCfg;
1076
1077 /* Physical Cell Group Configuration */
1078 typedef struct schPhyCellGrpCfg
1079 {
1080    SchPdschHarqAckCodebook    pdschHarqAckCodebook;
1081    int8_t     pNrFr1;
1082 }SchPhyCellGrpCfg;
1083
1084 /* Control resource set info */
1085 typedef struct schControlRsrcSet
1086 {
1087    uint8_t             cRSetId;                /* Control resource set id */
1088    uint8_t             freqDomainRsrc[FREQ_DOM_RSRC_SIZE];  /* Frequency domain resource */
1089    uint8_t             duration;
1090    SchREGMappingType   cceRegMappingType;
1091    SchPrecoderGranul   precoderGranularity;
1092    uint16_t            dmrsScramblingId;
1093 }SchControlRsrcSet;
1094
1095 /* Search Space info */
1096 typedef struct schSearchSpace
1097 {
1098    uint8_t                  searchSpaceId;
1099    uint8_t                  cRSetId;
1100    SchMSlotPeriodAndOffset  mSlotPeriodicityAndOffset;
1101    uint8_t                  mSymbolsWithinSlot[MONITORING_SYMB_WITHIN_SLOT_SIZE];
1102    SchAggrLevel             numCandidatesAggLevel1;      /* Number of candidates for aggregation level 1 */
1103    SchAggrLevel             numCandidatesAggLevel2;      /* Number of candidates for aggregation level 2 */
1104    SchAggrLevel             numCandidatesAggLevel4;      /* Number of candidates for aggregation level 4 */
1105    SchAggrLevel             numCandidatesAggLevel8;      /* Number of candidates for aggregation level 8 */
1106    SchAggrLevel             numCandidatesAggLevel16;     /* Number of candidates for aggregation level 16 */
1107    SchSearchSpaceType       searchSpaceType;
1108    uint8_t                  ueSpecificDciFormat;
1109 }SchSearchSpace;
1110
1111 /* PDCCH cofniguration */
1112 typedef struct schPdcchConfig
1113 {
1114    uint8_t           numCRsetToAddMod;
1115    SchControlRsrcSet  cRSetToAddModList[MAX_NUM_CRSET];           /* List of control resource set to add/modify */
1116    uint8_t           numCRsetToRel;
1117    uint8_t           cRSetToRelList[MAX_NUM_CRSET];              /* List of control resource set to release */
1118    uint8_t           numSearchSpcToAddMod;
1119    SchSearchSpace    searchSpcToAddModList[MAX_NUM_SEARCH_SPC];  /* List of search space to add/modify */
1120    uint8_t           numSearchSpcToRel;
1121    uint8_t           searchSpcToRelList[MAX_NUM_SEARCH_SPC];     /* List of search space to release */
1122 }SchPdcchConfig;
1123
1124 /* PDSCH time domain resource allocation */
1125 typedef struct schPdschTimeDomRsrcAlloc
1126 {
1127    uint8_t    *k0;
1128    SchTimeDomRsrcAllocMappingType    mappingType;
1129    uint8_t    startSymbol;
1130    uint8_t    symbolLength;
1131 }SchPdschTimeDomRsrcAlloc;
1132
1133
1134 typedef struct schPdschBundling
1135 {
1136    struct schStaticBundling
1137    {
1138      SchBundlingSizeSet2 size;
1139    }SchStaticBundling;
1140    struct schDynamicBundling
1141    {
1142      SchBundlingSizeSet1 sizeSet1;
1143      SchBundlingSizeSet2 sizeSet2;
1144    }SchDynamicBundling;
1145 }SchPdschBundling;
1146
1147 /* DMRS downlink configuration */
1148 typedef struct schDmrsDlCfg
1149 {
1150    SchDmrsAdditionPosition   addPos;       /* DMRS additional position */
1151 }SchDmrsDlCfg;
1152
1153 /* PDSCH Configuration */
1154 typedef struct schPdschConfig
1155 {
1156    SchDmrsDlCfg               dmrsDlCfgForPdschMapTypeA;
1157    SchResourceAllocType       resourceAllocType;
1158    uint8_t                    numTimeDomRsrcAlloc;
1159    SchPdschTimeDomRsrcAlloc   timeDomRsrcAllociList[MAX_NUM_DL_ALLOC]; /* PDSCH time domain DL resource allocation list */
1160    SchRBGSize                 rbgSize;
1161    SchCodeWordsSchedByDci     numCodeWordsSchByDci;                    /* Number of code words scheduled by DCI */
1162    SchBundlingType            bundlingType;
1163    SchPdschBundling           bundlingInfo;
1164 }SchPdschConfig;
1165
1166 /* Initial Downlink BWP */
1167 typedef struct schInitalDlBwp
1168 {
1169    bool             pdcchCfgPres;
1170    SchPdcchConfig   pdcchCfg;
1171    bool             pdschCfgPres;
1172    SchPdschConfig   pdschCfg;
1173    SchK0K1TimingInfoTbl k0K1InfoTbl;
1174 }SchInitalDlBwp;
1175
1176 /* BWP Downlink common */
1177 typedef struct schBwpDlCommon
1178 {
1179 }SchBwpDlCommon;
1180
1181 /* Downlink BWP information */
1182 typedef struct schDlBwpInfo
1183 {
1184    uint8_t          bwpId;
1185 }SchDlBwpInfo;
1186
1187 /* PDCCH Serving Cell configuration */
1188 typedef struct schPdschServCellCfg
1189 {
1190    uint8_t                  *maxMimoLayers;           
1191    SchNumHarqProcForPdsch   numHarqProcForPdsch;
1192    SchMaxCodeBlkGrpPerTB    *maxCodeBlkGrpPerTb;
1193    bool                     *codeBlkGrpFlushInd;
1194    SchPdschXOverhead        *xOverhead;
1195 }SchPdschServCellCfg;
1196
1197 /* PUCCH Configuration */
1198 typedef struct schPucchResrcSetInfo
1199 {
1200    uint8_t resrcSetId;
1201    uint8_t resrcListCount;
1202    uint8_t resrcList[MAX_NUM_PUCCH_PER_RESRC_SET];
1203    uint8_t maxPayLoadSize;
1204 }SchPucchResrcSetInfo;
1205
1206 typedef struct schPucchResrcSetCfg
1207 {
1208    uint8_t resrcSetToAddModListCount;
1209    SchPucchResrcSetInfo resrcSetToAddModList[MAX_NUM_PUCCH_RESRC_SET];
1210    uint8_t resrcSetToRelListCount;
1211    uint8_t resrcSetToRelList[MAX_NUM_PUCCH_RESRC];
1212 }SchPucchResrcSetCfg;
1213
1214 typedef struct schPucchFormat0
1215 {
1216    uint8_t initialCyclicShift;
1217    uint8_t numSymbols;
1218    uint8_t startSymbolIdx;
1219 }SchPucchFormat0;
1220
1221 typedef struct schPucchFormat1
1222 {
1223    uint8_t initialCyclicShift;
1224    uint8_t numSymbols;
1225    uint8_t startSymbolIdx;
1226    uint8_t timeDomOCC;
1227 }SchPucchFormat1;
1228
1229 typedef struct schPucchFormat2_3
1230 {
1231    uint8_t numPrbs;
1232    uint8_t numSymbols;
1233    uint8_t startSymbolIdx;
1234 }SchPucchFormat2_3;
1235
1236 typedef struct schPucchFormat4
1237 {
1238    uint8_t numSymbols;
1239    uint8_t occLen;
1240    uint8_t occIdx;
1241    uint8_t startSymbolIdx;
1242 }SchPucchFormat4;
1243
1244 typedef struct schPucchResrcInfo
1245 {
1246    uint8_t  resrcId;
1247    uint16_t startPrb;
1248    uint8_t  intraFreqHop;
1249    uint16_t secondPrbHop;
1250    uint8_t  pucchFormat;
1251    union{
1252       SchPucchFormat0   *format0; 
1253       SchPucchFormat1   *format1;
1254       SchPucchFormat2_3 *format2;
1255       SchPucchFormat2_3 *format3;
1256       SchPucchFormat4   *format4;
1257    }SchPucchFormat;
1258 }SchPucchResrcInfo;
1259
1260 typedef struct schPucchResrcCfg
1261 {
1262    uint8_t resrcToAddModListCount;
1263    SchPucchResrcInfo resrcToAddModList[MAX_NUM_PUCCH_RESRC];
1264    uint8_t resrcToRelListCount;
1265    uint8_t resrcToRelList[MAX_NUM_PUCCH_RESRC];
1266 }SchPucchResrcCfg;
1267
1268
1269 typedef struct schSchedReqResrcInfo
1270 {
1271    uint8_t resrcId;
1272    uint8_t requestId;
1273    uint8_t periodicity;
1274    uint16_t offset;
1275    uint8_t resrc;
1276 }SchSchedReqResrcInfo;
1277
1278 typedef struct schPucchSchedReqCfg
1279 {
1280    uint8_t           schedAddModListCount;
1281    SchSchedReqResrcInfo schedAddModList[MAX_NUM_SR_CFG_PER_CELL_GRP];
1282    uint8_t           schedRelListCount;
1283    uint8_t           schedRelList[MAX_NUM_SR_CFG_PER_CELL_GRP];
1284 }SchPucchSchedReqCfg;
1285
1286 typedef struct schSpatialRelationInfo
1287 {
1288    uint8_t spatialRelationId;
1289    uint8_t servCellIdx;
1290    uint8_t pathLossRefRSId;
1291    uint8_t p0PucchId;
1292    uint8_t closeLoopIdx;
1293 }SchSpatialRelationInfo;
1294
1295 typedef struct schPucchSpatialCfg
1296 {
1297    uint8_t spatialAddModListCount;
1298    SchSpatialRelationInfo spatialAddModList[MAX_NUM_SPATIAL_RELATIONS];
1299    uint8_t spatialRelListCount;
1300    uint8_t spatialRelList[MAX_NUM_SPATIAL_RELATIONS];
1301 }SchPucchSpatialCfg;
1302
1303 typedef struct schP0PucchCfg
1304 {
1305    uint8_t p0PucchId;
1306    int     p0PucchVal;
1307 }SchP0PucchCfg;
1308
1309 typedef struct schPathLossRefRSCfg
1310 {
1311    uint8_t pathLossRefRSId;
1312 }SchPathLossRefRSCfg;
1313
1314 typedef struct schPucchMultiCsiCfg
1315 {
1316    uint8_t  multiCsiResrcListCount;
1317    uint8_t  multiCsiResrcList[MAX_NUM_PUCCH_RESRC-1];
1318 }SchPucchMultiCsiCfg;
1319
1320 typedef struct schPucchDlDataToUlAck
1321 {
1322    uint8_t  dlDataToUlAckListCount;
1323    uint8_t  dlDataToUlAckList[MAX_NUM_DL_DATA_TO_UL_ACK];
1324 }SchPucchDlDataToUlAck;
1325
1326 typedef struct schPucchPowerControl
1327 {
1328    int deltaF_Format0;
1329    int deltaF_Format1;
1330    int deltaF_Format2;
1331    int deltaF_Format3;
1332    int deltaF_Format4;
1333    uint8_t p0SetCount;
1334    SchP0PucchCfg p0Set[MAX_NUM_PUCCH_P0_PER_SET];
1335    uint8_t pathLossRefRSListCount;
1336    SchPathLossRefRSCfg pathLossRefRSList[MAX_NUM_PATH_LOSS_REF_RS];
1337 }SchPucchPowerControl;
1338
1339 typedef struct schPucchCfg
1340 {
1341    SchPucchResrcSetCfg   *resrcSet;
1342    SchPucchResrcCfg      *resrc;
1343    SchPucchFormatCfg     *format1; 
1344    SchPucchFormatCfg     *format2; 
1345    SchPucchFormatCfg     *format3; 
1346    SchPucchFormatCfg     *format4;
1347    SchPucchSchedReqCfg   *schedReq;
1348    SchPucchMultiCsiCfg   *multiCsiCfg;
1349    SchPucchSpatialCfg    *spatialInfo;
1350    SchPucchDlDataToUlAck *dlDataToUlAck;
1351    SchPucchPowerControl  *powerControl;
1352 }SchPucchCfg;
1353
1354 /* Transform precoding disabled */
1355 typedef struct schTransPrecodDisabled
1356 {
1357    uint16_t   scramblingId0;
1358 }SchTransPrecodDisabled;
1359
1360 /* DMRS Uplink configuration */
1361 typedef struct SchDmrsUlCfg
1362 {
1363    SchDmrsAdditionPosition    addPos;               /* DMRS additional position */
1364    SchTransPrecodDisabled     transPrecodDisabled;  /* Transform precoding disabled */
1365 }SchDmrsUlCfg;
1366
1367 /* PUSCH Configuration */
1368 typedef struct schPuschCfg
1369 {
1370    uint8_t                    dataScramblingId;
1371    SchDmrsUlCfg               dmrsUlCfgForPuschMapTypeA;
1372    SchResourceAllocType       resourceAllocType;
1373    uint8_t                    numTimeDomRsrcAlloc;
1374    SchPuschTimeDomRsrcAlloc   timeDomRsrcAllocList[MAX_NUM_UL_ALLOC]; /* PUSCH time domain UL resource allocation list */
1375    SchTransformPrecoder       transformPrecoder;
1376 }SchPuschCfg;
1377
1378 /* Initial Uplink BWP */
1379 typedef struct schInitialUlBwp
1380 {
1381    bool          pucchCfgPres;
1382    SchPucchCfg   pucchCfg;
1383    bool          puschCfgPres;
1384    SchPuschCfg   puschCfg;
1385    SchK2TimingInfoTbl k2InfoTbl;
1386 }SchInitialUlBwp;
1387
1388 /* Uplink BWP information */
1389 typedef struct schUlBwpInfo
1390 {
1391    uint8_t        bwpId;
1392 }SchUlBwpInfo;
1393
1394 /* Serving cell configuration */
1395 typedef struct schServCellCfgInfo
1396 {
1397    SchInitalDlBwp        initDlBwp;
1398    uint8_t               numDlBwpToAdd;
1399    SchDlBwpInfo          DlBwpToAddList[MAX_NUM_BWP];
1400    uint8_t               firstActvDlBwpId;
1401    uint8_t               defaultDlBwpId;
1402    uint8_t               *bwpInactivityTmr;
1403    SchPdschServCellCfg   pdschServCellCfg;
1404    SchInitialUlBwp       initUlBwp;
1405    uint8_t               numUlBwpToAdd;
1406    SchUlBwpInfo          UlBwpToAddList[MAX_NUM_BWP];
1407    uint8_t               firstActvUlBwpId;
1408 }SchServCellCfgInfo;
1409
1410 typedef struct schNonDynFiveQi
1411 {
1412    uint16_t   fiveQi;
1413    uint8_t    priorLevel;
1414    uint16_t   avgWindow;
1415    uint16_t   maxDataBurstVol;
1416 }SchNonDynFiveQi;
1417
1418 typedef struct schDynFiveQi
1419 {
1420    uint8_t    priorLevel;
1421    uint16_t   packetDelayBudget;
1422    uint8_t    packetErrRateScalar;
1423    uint8_t    packetErrRateExp;
1424    uint16_t   fiveQi;
1425    uint8_t    delayCritical;
1426    uint16_t   avgWindow;
1427    uint16_t   maxDataBurstVol;
1428 }SchDynFiveQi;
1429
1430 typedef struct schNgRanAllocAndRetPri
1431 {
1432    uint8_t priorityLevel;
1433    uint8_t preEmptionCap;
1434    uint8_t preEmptionVul;
1435 }SchNgRanAllocAndRetPri;
1436
1437 typedef struct schGrbQosFlowInfo
1438 {
1439    uint32_t maxFlowBitRateDl;
1440    uint32_t maxFlowBitRateUl;
1441    uint32_t guarFlowBitRateDl;
1442    uint32_t guarFlowBitRateUl;
1443 }SchGrbQosFlowInfo;
1444
1445 /* DRB QoS */
1446 typedef struct schDrbQos
1447 {
1448    SchQosType  fiveQiType;   /* Dynamic or non-dynamic */ 
1449    union
1450    {
1451       SchNonDynFiveQi   nonDyn5Qi;
1452       SchDynFiveQi      dyn5Qi;
1453    }u;
1454    SchNgRanAllocAndRetPri  ngRanRetPri;
1455    SchGrbQosFlowInfo       grbQosFlowInfo;
1456    uint16_t                pduSessionId;
1457    uint32_t                ulPduSessAggMaxBitRate;   /* UL PDU Session Aggregate max bit rate */
1458 }SchDrbQosInfo;
1459
1460 typedef struct schSnssai
1461 {
1462    uint8_t   sst;
1463    uint8_t   sd[SD_SIZE];
1464 }SchSnssai;
1465
1466 /* Special cell configuration */
1467 typedef struct schSpCellCfg
1468 {
1469    uint8_t           servCellIdx;
1470    SchServCellCfgInfo   servCellCfg;
1471 }SchSpCellCfg;
1472
1473 /* Uplink logical channel configuration */
1474 typedef struct SchUlLcCfg
1475 {
1476    uint8_t priority;
1477    uint8_t lcGroup;
1478    uint8_t schReqId;
1479    uint8_t pbr;        // prioritisedBitRate
1480    uint8_t bsd;        // bucketSizeDuration
1481 }SchUlLcCfg;
1482
1483 /* Downlink logical channel configuration */
1484 typedef struct schDlLcCfg
1485 {
1486    uint8_t lcp;      // logical Channel Prioritization
1487 }SchDlLcCfg;
1488
1489 /* Logical Channel configuration */
1490 typedef struct schLcCfg
1491 {
1492    ConfigType     configType;
1493    uint8_t        lcId;
1494    SchDrbQosInfo  *drbQos;
1495    SchSnssai      *snssai;
1496    SchDlLcCfg     dlLcCfg;
1497    SchUlLcCfg     ulLcCfg;
1498 }SchLcCfg;
1499
1500 /* Aggregate max bit rate */
1501 typedef struct schAmbrCfg
1502 {
1503    uint32_t   ulBr;   /* Ul BitRate */
1504 }SchAmbrCfg;
1505
1506 typedef struct schModulationInfo
1507 {
1508    uint8_t      modOrder;
1509    uint8_t      mcsIndex;
1510    SchMcsTable  mcsTable;
1511 }SchModulationInfo;
1512
1513 /* UE configuration */
1514 typedef struct schUeCfg
1515 {
1516    uint16_t        cellId;
1517    uint16_t        crnti;
1518    bool macCellGrpCfgPres;
1519    SchMacCellGrpCfg   macCellGrpCfg;
1520    bool phyCellGrpCfgPres;
1521    SchPhyCellGrpCfg   phyCellGrpCfg;
1522    bool spCellCfgPres;
1523    SchSpCellCfg       spCellCfg;
1524    SchAmbrCfg         *ambrCfg;
1525    SchModulationInfo  dlModInfo;
1526    SchModulationInfo  ulModInfo;
1527    uint8_t            numLcs;
1528    SchLcCfg           schLcCfg[MAX_NUM_LC];
1529 }SchUeCfg;
1530
1531 typedef struct schUeCfgRsp
1532 {
1533    uint16_t   ueIdx;
1534    uint16_t   cellId;
1535    uint16_t   crnti;
1536    SchMacRsp  rsp;
1537    SchFailureCause cause;
1538 }SchUeCfgRsp;
1539
1540 typedef struct schUeDelete
1541 {
1542    uint16_t   cellId;
1543    uint16_t   crnti;
1544 }SchUeDelete;
1545
1546 typedef struct schUeDeleteRsp
1547 {
1548    uint16_t   cellId;
1549    uint16_t   crnti;
1550    SchMacRsp  rsp;
1551    ErrorCause cause;
1552 }SchUeDeleteRsp;
1553
1554 typedef struct schCellDelete 
1555 {
1556    uint16_t   cellId;
1557 }SchCellDelete;
1558
1559
1560 typedef struct schCellDeleteRsp
1561 {
1562    uint16_t   cellId;
1563    SchMacRsp  rsp;
1564 }SchCellDeleteRsp;
1565
1566 typedef struct dataVolInfo
1567 {
1568    uint8_t  lcgId;
1569    uint32_t dataVol;
1570 }DataVolInfo;
1571
1572 typedef struct ulBufferStatusRptInd
1573 {
1574    uint16_t    cellId;
1575    uint16_t    crnti;
1576    BsrType     bsrType;
1577    uint8_t     numLcg;
1578    DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS];
1579 }UlBufferStatusRptInd;
1580
1581 typedef struct srUciIndInfo
1582 {
1583    uint16_t    cellId;
1584    uint16_t    crnti;
1585    SlotTimingInfo slotInd;
1586    uint8_t     numSrBits;
1587    uint8_t     srPayload[MAX_SR_BITS_IN_BYTES];
1588 }SrUciIndInfo;
1589
1590 /* function pointers */
1591
1592 typedef uint8_t (*SchCellCfgCfmFunc)    ARGS((
1593          Pst            *pst,           /* Post Structure */                         
1594          SchCellCfgCfm  *schCellCfgCfm  /* Cell Cfg Cfm */
1595          ));
1596
1597 typedef uint8_t (*SchCellCfgFunc)    ARGS((
1598          Pst         *pst,           /* Post Structure */                         
1599          SchCellCfg  *schCellCfg     /* Cell Cfg  */
1600          ));
1601
1602 typedef uint8_t (*SchMacDlAllocFunc)     ARGS((                     
1603          Pst            *pst,          /* Post Structure */                         
1604          DlSchedInfo    *dlSchedInfo   /* dl allocation Info */                      
1605          ));
1606
1607 typedef uint8_t (*SchMacUlSchInfoFunc)     ARGS((                     
1608          Pst         *pst,           /* Post Structure */                         
1609          UlSchedInfo *ulSchedInfo    /* UL Alloc Sch  Info */                      
1610          ));
1611
1612 typedef uint8_t (*MacSchRachIndFunc) ARGS((
1613          Pst         *pst,         /* Post structure */
1614          RachIndInfo *rachInd));    /* Rach Indication Info */
1615
1616 typedef uint8_t (*MacSchCrcIndFunc) ARGS(( 
1617          Pst         *pst,         /* Post structure */
1618          CrcIndInfo  *crcInd));     /* CRC Info */
1619
1620 typedef uint8_t (*MacSchDlRlcBoInfoFunc) ARGS((
1621          Pst         *pst,         /* Post structure */
1622          DlRlcBoInfo *dlBoInfo));   /* DL BO Info */
1623
1624 typedef uint8_t (*MacSchAddUeConfigReqFunc) ARGS((
1625          Pst         *pst,           /* Post structure */
1626          SchUeCfg    *ueCfgToSch));   /* Scheduler UE Cfg */
1627
1628 typedef uint8_t (*SchUeCfgRspFunc) ARGS((
1629          Pst         *pst,           /* Post structure */
1630          SchUeCfgRsp *cfgRsp));       /* Scheduler UE Cfg response */
1631
1632 typedef uint8_t (*MacSchSlotIndFunc) ARGS((
1633          Pst         *pst,          /* Post structure */
1634          SlotTimingInfo *slotInd));    /* Slot Info */
1635
1636 typedef uint8_t (*MacSchBsrFunc)       ARGS((
1637    Pst                  *pst,
1638    UlBufferStatusRptInd *bsrInd
1639 ));
1640
1641 typedef uint8_t (*MacSchSrUciIndFunc) ARGS(( 
1642          Pst         *pst,         /* Post structure */
1643          SrUciIndInfo  *uciInd));    /* UCI IND Info */
1644
1645 typedef uint8_t (*MacSchModUeConfigReqFunc) ARGS((
1646          Pst         *pst,           /* Post structure */
1647          SchUeCfg    *ueCfgToSch));   /* Scheduler UE Cfg */
1648
1649 typedef uint8_t (*SchUeReCfgRspFunc) ARGS((
1650          Pst         *pst,           /* Post structure */
1651          SchUeCfgRsp *cfgRsp));       /* Scheduler UE Cfg response */
1652
1653 typedef uint8_t (*MacSchUeDeleteReqFunc) ARGS((
1654    Pst         *pst,           /* Post structure */
1655    SchUeDelete *schUeDel)); /*Scheduler UE Del*/
1656
1657 typedef uint8_t (*SchUeDeleteRspFunc) ARGS((
1658    Pst          *pst,           /* Post structure */
1659    SchUeDeleteRsp *delRsp));       /* Scheduler UE delete response */
1660
1661 typedef uint8_t (*MacSchCellDeleteReqFunc) ARGS((
1662    Pst         *pst,           /* Post structure */
1663    SchCellDelete *schCellDelete)); /*Scheduler UE Del*/
1664
1665 typedef uint8_t (*SchCellDeleteRspFunc) ARGS((
1666    Pst          *pst,           /* Post structure */
1667    SchCellDeleteRsp *schCellDeleteRsp));       /* Scheduler UE delete response */
1668
1669 /* function declarations */
1670 uint8_t packMacSchSlotInd(Pst *pst, SlotTimingInfo *slotInd);
1671 uint8_t packSchMacDlAlloc(Pst *pst, DlSchedInfo  *dlSchedInfo);
1672 uint8_t packSchMacUlSchInfo(Pst *pst, UlSchedInfo *ulSchedInfo);
1673 uint8_t packSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
1674 uint8_t packSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
1675 uint8_t MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo);
1676 uint8_t MacProcSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
1677 uint8_t MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
1678 uint8_t SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg);
1679 uint8_t schActvInit(Ent entity, Inst instId, Region region, Reason reason);
1680 uint8_t MacProcUlSchInfo(Pst *pst, UlSchedInfo *ulSchedInfo);
1681 uint8_t packMacSchRachInd(Pst *pst, RachIndInfo *rachInd);
1682 uint8_t MacSchRachInd(Pst *pst, RachIndInfo *rachInd);
1683 uint8_t packMacSchCrcInd(Pst *pst, CrcIndInfo *crcInd);
1684 uint8_t MacSchCrcInd(Pst *pst, CrcIndInfo *crcInd);
1685 uint8_t packMacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo);
1686 uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo);
1687 uint8_t packMacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfgToSch);
1688 uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfgToSch);
1689 uint8_t packSchUeCfgRsp(Pst *pst, SchUeCfgRsp *cfgRsp);
1690 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *cfgRsp);
1691 uint8_t MacSchSlotInd ARGS((Pst * pst, SlotTimingInfo * slotInd));
1692 uint8_t packMacSchSlotInd(Pst * pst, SlotTimingInfo * slotInd);
1693 uint8_t unpackMacSchSlotInd(MacSchSlotIndFunc func, Pst *pst, Buffer  *mBuf);
1694 uint8_t packMacSchBsr(Pst *pst, UlBufferStatusRptInd *bsrInd);
1695 uint8_t MacSchBsr(Pst *pst, UlBufferStatusRptInd *bsrInd);
1696 uint8_t packMacSchSrUciInd(Pst *pst, SrUciIndInfo *uciInd);
1697 uint8_t MacSchSrUciInd(Pst *pst, SrUciIndInfo *uciInd);
1698 uint8_t packMacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfgToSch);
1699 uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfgToSch);
1700 uint8_t packSchUeReconfigRsp(Pst *pst, SchUeCfgRsp *cfgRsp);
1701 uint8_t MacProcSchUeReconfigRsp(Pst *pst, SchUeCfgRsp *cfgRsp);
1702 uint8_t packMacSchUeDeleteReq(Pst *pst,  SchUeDelete *schUeDel);
1703 uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete  *ueDelete);
1704 uint8_t packSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp  *delRsp);
1705 uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp);
1706 uint8_t packMacSchCellDeleteReq(Pst *pst,  SchCellDelete *schCellDelete);
1707 uint8_t MacSchCellDeleteReq(Pst *pst, SchCellDelete  *schCellDelete);
1708 uint8_t packSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp  *schCellDeleteRsp);
1709 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDeleteRsp);
1710
1711 /**********************************************************************
1712   End of file
1713  **********************************************************************/
1714