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