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