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