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