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