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