Encoding of MSG3 UL grant in RAR PDU [Issue-ID: ODUHIGH-342]
[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 msg3UlGrant
758 {
759    uint8_t         freqHopFlag;
760    uint16_t        bwpSize;
761    FreqDomainAlloc msg3FreqAlloc;
762    uint8_t         k2Index;
763    uint8_t         mcs;
764    uint8_t         tpc;
765    uint8_t         csiReq;
766 }Msg3UlGrant;
767
768 typedef struct rarInfo
769 {
770    uint16_t        raRnti;
771    uint8_t         RAPID;
772    uint16_t        ta;
773    Msg3UlGrant     ulGrant;
774    uint16_t        tcrnti;
775    uint8_t         rarPdu[RAR_PAYLOAD_SIZE];
776    uint8_t         rarPduLen;
777 }RarInfo;
778
779 typedef struct rarAlloc
780 {
781    RarInfo rarInfo;
782    BwpCfg  bwp;
783    PdcchCfg rarPdcchCfg;
784    PdschCfg rarPdschCfg;
785 }RarAlloc;
786
787 typedef struct dlMsgInfo
788 {
789    uint16_t crnti;
790    uint8_t  ndi;
791    uint8_t  harqProcNum;
792    uint8_t  dlAssignIdx;
793    uint8_t  pucchTpc;
794    uint8_t  pucchResInd;
795    uint8_t  harqFeedbackInd;
796    uint8_t  dciFormatId;
797    bool     isMsg4Pdu;
798    uint16_t  dlMsgPduLen;
799    uint8_t  *dlMsgPdu;
800 }DlMsgInfo;
801
802 typedef struct lcSchInfo
803 {
804    uint8_t   lcId;
805    uint32_t  schBytes; /* Number of scheduled bytes */
806 }LcSchInfo;
807
808 typedef struct dlMsgAlloc
809 {
810    uint16_t   crnti;
811    uint8_t    numLc;
812    LcSchInfo  lcSchInfo[MAX_NUM_LC]; /* Scheduled LC info */
813    BwpCfg     bwp;
814    PdcchCfg   dlMsgPdcchCfg;
815    PdschCfg   dlMsgPdschCfg;
816    DlMsgInfo  dlMsgInfo;
817 }DlMsgAlloc;
818
819 typedef struct schSlotValue
820 {
821    SlotTimingInfo currentTime;
822    SlotTimingInfo broadcastTime;
823    SlotTimingInfo rarTime;
824    SlotTimingInfo dlMsgTime;
825    SlotTimingInfo ulDciTime;
826 }SchSlotValue;
827
828 typedef struct format0_0
829 {
830    uint8_t         resourceAllocType;
831    /* since we are using type-1, hence rbBitmap excluded */
832    FreqDomainAlloc freqAlloc;
833    TimeDomainAlloc timeAlloc;
834    uint16_t        rowIndex;
835    uint8_t         mcs;
836    uint8_t         harqProcId;   /* HARQ Process ID */
837    bool            puschHopFlag;
838    bool            freqHopFlag;
839    uint8_t         ndi;    /* NDI */
840    uint8_t         rv;     /* Redundancy Version */
841    uint8_t         tpcCmd;
842    bool            sUlCfgd;
843 }Format0_0;
844
845 typedef struct format0_1
846 {
847 /* TBD */
848
849 }Format0_1;
850
851 typedef struct format1_0
852 {
853 /* TBD */
854
855 }Format1_0;
856
857 typedef struct format1_1
858 {
859 /* TBD */
860 }Format1_1;
861
862 typedef struct dciInfo
863 {
864    uint16_t      cellId;   
865    uint16_t      crnti;          /* CRNI */
866    SlotTimingInfo   slotIndInfo;    /* Slot Info: sfn, slot number */
867    BwpCfg        bwpCfg;         /* BWP Cfg */
868    CoresetCfg    coresetCfg;     /* Coreset1 Cfg */
869    FormatType    formatType;     /* DCI Format */
870    union
871    {
872       Format0_0  format0_0;      /* Format 0_0 */
873       Format0_1  format0_1;      /* Format 0_1 */
874       Format1_0  format1_0;      /* Format 1_0 */
875       Format1_1  format1_1;      /* Format 1_1 */
876    }format;
877    DlDCI    dciInfo;
878 }DciInfo;
879
880
881 typedef struct dlSchedInfo
882 {
883    uint16_t cellId;  /* Cell Id */
884    SchSlotValue schSlotValue;
885
886    /* Allocation for broadcast messages */
887    bool isBroadcastPres;
888    DlBrdcstAlloc brdcstAlloc;
889
890    /* Allocation for RAR message */
891    //uint8_t isRarPres;
892    RarAlloc *rarAlloc;
893
894    /* Allocation from MSG4 */
895    //Msg4Alloc *msg4Alloc;
896
897    /* UL grant in response to BSR */
898    DciInfo    *ulGrant;
899
900    /* Allocation from dedicated DL msg */
901    DlMsgAlloc *dlMsgAlloc;
902
903 }DlSchedInfo;
904
905 typedef struct tbInfo
906 {
907    uint8_t  qamOrder;  /* Modulation Order */
908    uint8_t  mcs;       /* MCS */
909    SchMcsTable  mcsTable;  /* MCS Table */
910    uint8_t  ndi;       /* NDI */
911    uint8_t  rv;        /* Redundancy Version */
912    uint16_t tbSize;    /* TB Size */
913 }TbInfo;
914
915 typedef struct schPuschInfo
916 {
917    uint16_t         crnti;
918    uint8_t          harqProcId;   /* HARQ Process ID */
919    uint8_t          resAllocType; /* Resource allocation type */
920    FreqDomainAlloc  fdAlloc;      /* Freq domain allocation */
921    TimeDomainAlloc  tdAlloc;      /* Time domain allocation */
922    TbInfo           tbInfo;       /* TB info */
923    uint8_t          dmrsMappingType;
924    uint8_t          nrOfDmrsSymbols;
925    uint8_t          dmrsAddPos;
926 }SchPuschInfo;
927
928 typedef struct schPucchFormatCfg
929 {
930    uint8_t interSlotFreqHop;
931    uint8_t addDmrs;
932    uint8_t maxCodeRate;
933    uint8_t numSlots;
934    bool    pi2BPSK;
935    bool    harqAckCSI;
936 }SchPucchFormatCfg;
937
938 typedef struct schPucchInfo
939 {
940    uint16_t         rnti;
941    uint8_t          pucchFormat;
942    FreqDomainAlloc  fdAlloc;      /* Freq domain allocation */
943    TimeDomainAlloc  tdAlloc;      /* Time domain allocation */
944    uint8_t          srFlag;
945    uint8_t          harqFlag;
946    uint8_t          numHarqBits;
947    uint8_t          uciFlag;
948    uint8_t          numUciBits;
949    uint8_t          intraFreqHop;
950    uint16_t         secondPrbHop;
951    uint8_t          initialCyclicShift;
952    uint8_t          occLen;
953    uint8_t          occIdx;
954    uint8_t          timeDomOCC;
955    SchPucchFormatCfg cmnFormatCfg;
956 }SchPucchInfo;
957
958 typedef struct ulSchedInfo
959 {
960    uint16_t      cellId;         /* Cell Id */
961    uint16_t      crnti;          /* CRNI */
962    SlotTimingInfo   slotIndInfo;    /* Slot Info: sfn, slot number */
963    uint8_t       dataType;       /* Type of info being scheduled */
964    PrachSchInfo  prachSchInfo;   /* Prach scheduling info */
965    SchPuschInfo  schPuschInfo;   /* Pusch scheduling info */
966    SchPucchInfo  schPucchInfo;   /* Pusch scheduling info */
967 }UlSchedInfo;
968
969 typedef struct rachIndInfo
970 {
971    uint16_t    cellId;
972    uint16_t    crnti;
973    SlotTimingInfo timingInfo;
974    uint8_t     slotIdx;
975    uint8_t     symbolIdx;
976    uint8_t     freqIdx;
977    uint8_t     preambleIdx;
978    uint16_t    timingAdv;
979 }RachIndInfo;
980
981
982 typedef struct crcIndInfo
983 {
984    uint16_t    cellId;
985    uint16_t    crnti;
986    SlotTimingInfo timingInfo;
987    uint16_t    numCrcInd;
988    uint8_t     crcInd[MAX_NUMBER_OF_CRC_IND_BITS];
989 }CrcIndInfo;
990
991 typedef struct boInfo
992 {
993    uint8_t   lcId;
994    uint32_t  dataVolume;
995 }BOInfo;
996
997 typedef struct dlRlcBOInfo
998 {
999    uint16_t    cellId;
1000    uint16_t    crnti;
1001    uint8_t     lcId;
1002    uint32_t    dataVolume;
1003 }DlRlcBoInfo;
1004
1005 /* Info of Scheduling Request to Add/Modify */
1006 typedef struct schSchedReqInfo
1007 {
1008    uint8_t              schedReqId;
1009    SchSrProhibitTimer   srProhibitTmr;
1010    SchSrTransMax        srTransMax;
1011 }SchSchedReqInfo;
1012
1013 /* Scheduling Request Configuration */
1014 typedef struct schSchedReqCfg
1015 {
1016    uint8_t          addModListCount;
1017    SchSchedReqInfo  addModList[MAX_NUM_SR_CFG_PER_CELL_GRP];   /* List of Scheduling req to be added/modified */
1018    uint8_t          relListCount;
1019    uint8_t          relList[MAX_NUM_SR_CFG_PER_CELL_GRP];      /* list of scheduling request Id to be deleted */
1020 }SchSchedReqCfg;
1021
1022 /* Info of Tag to Add/Modify */
1023 typedef struct schTagInfo
1024 {
1025    uint8_t       tagId;
1026    SchTimeAlignmentTimer  timeAlignmentTmr;
1027 }SchTagInfo;
1028
1029 /* Timing Advance Group Configuration */
1030 typedef struct schTagCfg
1031 {
1032    uint8_t      addModListCount;
1033    SchTagInfo   addModList[MAX_NUM_TAGS];    /* List of Tag to Add/Modify */
1034    uint8_t      relListCount;
1035    uint8_t      relList[MAX_NUM_TAGS];       /* list of Tag Id to release */
1036 }SchTagCfg;
1037
1038 /* Configuration for Power headroom reporting */
1039 typedef struct schPhrCfg
1040 {
1041    SchPhrPeriodicTimer       periodicTmr;
1042    SchPhrProhibitTimer       prohibitTmr;
1043    SchPhrTxPwrFactorChange   txpowerFactorChange;
1044    bool                      multiplePhr;
1045    bool                      dummy;
1046    bool                      type2OtherCell;
1047    SchPhrModeOtherCG         modeOtherCG;
1048 }SchPhrCfg;
1049
1050 /* MAC cell Group configuration */
1051 typedef struct schMacCellGrpCfg
1052 {
1053    SchSchedReqCfg   schedReqCfg;
1054    SchTagCfg        tagCfg;
1055    SchPhrCfg        phrCfg;             /* To be used only if phrCfgSetupPres is true */      
1056 }SchMacCellGrpCfg;
1057
1058 /* Physical Cell Group Configuration */
1059 typedef struct schPhyCellGrpCfg
1060 {
1061    SchPdschHarqAckCodebook    pdschHarqAckCodebook;
1062    int8_t     pNrFr1;
1063 }SchPhyCellGrpCfg;
1064
1065 /* Control resource set info */
1066 typedef struct schControlRsrcSet
1067 {
1068    uint8_t             cRSetId;                /* Control resource set id */
1069    uint8_t             freqDomainRsrc[FREQ_DOM_RSRC_SIZE];  /* Frequency domain resource */
1070    uint8_t             duration;
1071    SchREGMappingType   cceRegMappingType;
1072    SchPrecoderGranul   precoderGranularity;
1073    uint16_t            dmrsScramblingId;
1074 }SchControlRsrcSet;
1075
1076 /* Search Space info */
1077 typedef struct schSearchSpace
1078 {
1079    uint8_t                  searchSpaceId;
1080    uint8_t                  cRSetId;
1081    SchMSlotPeriodAndOffset  mSlotPeriodicityAndOffset;
1082    uint8_t                  mSymbolsWithinSlot[MONITORING_SYMB_WITHIN_SLOT_SIZE];
1083    SchAggrLevel             numCandidatesAggLevel1;      /* Number of candidates for aggregation level 1 */
1084    SchAggrLevel             numCandidatesAggLevel2;      /* Number of candidates for aggregation level 2 */
1085    SchAggrLevel             numCandidatesAggLevel4;      /* Number of candidates for aggregation level 4 */
1086    SchAggrLevel             numCandidatesAggLevel8;      /* Number of candidates for aggregation level 8 */
1087    SchAggrLevel             numCandidatesAggLevel16;     /* Number of candidates for aggregation level 16 */
1088    SchSearchSpaceType       searchSpaceType;
1089    uint8_t                  ueSpecificDciFormat;
1090 }SchSearchSpace;
1091
1092 /* PDCCH cofniguration */
1093 typedef struct schPdcchConfig
1094 {
1095    uint8_t           numCRsetToAddMod;
1096    SchControlRsrcSet  cRSetToAddModList[MAX_NUM_CRSET];           /* List of control resource set to add/modify */
1097    uint8_t           numCRsetToRel;
1098    uint8_t           cRSetToRelList[MAX_NUM_CRSET];              /* List of control resource set to release */
1099    uint8_t           numSearchSpcToAddMod;
1100    SchSearchSpace    searchSpcToAddModList[MAX_NUM_SEARCH_SPC];  /* List of search space to add/modify */
1101    uint8_t           numSearchSpcToRel;
1102    uint8_t           searchSpcToRelList[MAX_NUM_SEARCH_SPC];     /* List of search space to release */
1103 }SchPdcchConfig;
1104
1105 /* PDSCH time domain resource allocation */
1106 typedef struct schPdschTimeDomRsrcAlloc
1107 {
1108    uint8_t    *k0;
1109    SchTimeDomRsrcAllocMappingType    mappingType;
1110    uint8_t    startSymbol;
1111    uint8_t    symbolLength;
1112 }SchPdschTimeDomRsrcAlloc;
1113
1114
1115 typedef struct schPdschBundling
1116 {
1117    struct schStaticBundling
1118    {
1119      SchBundlingSizeSet2 size;
1120    }SchStaticBundling;
1121    struct schDynamicBundling
1122    {
1123      SchBundlingSizeSet1 sizeSet1;
1124      SchBundlingSizeSet2 sizeSet2;
1125    }SchDynamicBundling;
1126 }SchPdschBundling;
1127
1128 /* DMRS downlink configuration */
1129 typedef struct schDmrsDlCfg
1130 {
1131    SchDmrsAdditionPosition   addPos;       /* DMRS additional position */
1132 }SchDmrsDlCfg;
1133
1134 /* PDSCH Configuration */
1135 typedef struct schPdschConfig
1136 {
1137    SchDmrsDlCfg               dmrsDlCfgForPdschMapTypeA;
1138    SchResourceAllocType       resourceAllocType;
1139    uint8_t                    numTimeDomRsrcAlloc;
1140    SchPdschTimeDomRsrcAlloc   timeDomRsrcAllociList[MAX_NUM_DL_ALLOC]; /* PDSCH time domain DL resource allocation list */
1141    SchRBGSize                 rbgSize;
1142    SchCodeWordsSchedByDci     numCodeWordsSchByDci;                    /* Number of code words scheduled by DCI */
1143    SchBundlingType            bundlingType;
1144    SchPdschBundling           bundlingInfo;
1145 }SchPdschConfig;
1146
1147 /* Initial Downlink BWP */
1148 typedef struct schInitalDlBwp
1149 {
1150    bool             pdcchCfgPres;
1151    SchPdcchConfig   pdcchCfg;
1152    bool             pdschCfgPres;
1153    SchPdschConfig   pdschCfg;
1154    SchK0K1TimingInfoTbl k0K1InfoTbl;
1155 }SchInitalDlBwp;
1156
1157 /* BWP Downlink common */
1158 typedef struct schBwpDlCommon
1159 {
1160 }SchBwpDlCommon;
1161
1162 /* Downlink BWP information */
1163 typedef struct schDlBwpInfo
1164 {
1165    uint8_t          bwpId;
1166 }SchDlBwpInfo;
1167
1168 /* PDCCH Serving Cell configuration */
1169 typedef struct schPdschServCellCfg
1170 {
1171    uint8_t                  *maxMimoLayers;           
1172    SchNumHarqProcForPdsch   numHarqProcForPdsch;
1173    SchMaxCodeBlkGrpPerTB    *maxCodeBlkGrpPerTb;
1174    bool                     *codeBlkGrpFlushInd;
1175    SchPdschXOverhead        *xOverhead;
1176 }SchPdschServCellCfg;
1177
1178 /* PUCCH Configuration */
1179 typedef struct schPucchResrcSetInfo
1180 {
1181    uint8_t resrcSetId;
1182    uint8_t resrcListCount;
1183    uint8_t resrcList[MAX_NUM_PUCCH_PER_RESRC_SET];
1184    uint8_t maxPayLoadSize;
1185 }SchPucchResrcSetInfo;
1186
1187 typedef struct schPucchResrcSetCfg
1188 {
1189    uint8_t resrcSetToAddModListCount;
1190    SchPucchResrcSetInfo resrcSetToAddModList[MAX_NUM_PUCCH_RESRC_SET];
1191    uint8_t resrcSetToRelListCount;
1192    uint8_t resrcSetToRelList[MAX_NUM_PUCCH_RESRC];
1193 }SchPucchResrcSetCfg;
1194
1195 typedef struct schPucchFormat0
1196 {
1197    uint8_t initialCyclicShift;
1198    uint8_t numSymbols;
1199    uint8_t startSymbolIdx;
1200 }SchPucchFormat0;
1201
1202 typedef struct schPucchFormat1
1203 {
1204    uint8_t initialCyclicShift;
1205    uint8_t numSymbols;
1206    uint8_t startSymbolIdx;
1207    uint8_t timeDomOCC;
1208 }SchPucchFormat1;
1209
1210 typedef struct schPucchFormat2_3
1211 {
1212    uint8_t numPrbs;
1213    uint8_t numSymbols;
1214    uint8_t startSymbolIdx;
1215 }SchPucchFormat2_3;
1216
1217 typedef struct schPucchFormat4
1218 {
1219    uint8_t numSymbols;
1220    uint8_t occLen;
1221    uint8_t occIdx;
1222    uint8_t startSymbolIdx;
1223 }SchPucchFormat4;
1224
1225 typedef struct schPucchResrcInfo
1226 {
1227    uint8_t  resrcId;
1228    uint16_t startPrb;
1229    uint8_t  intraFreqHop;
1230    uint16_t secondPrbHop;
1231    uint8_t  pucchFormat;
1232    union{
1233       SchPucchFormat0   *format0; 
1234       SchPucchFormat1   *format1;
1235       SchPucchFormat2_3 *format2;
1236       SchPucchFormat2_3 *format3;
1237       SchPucchFormat4   *format4;
1238    }SchPucchFormat;
1239 }SchPucchResrcInfo;
1240
1241 typedef struct schPucchResrcCfg
1242 {
1243    uint8_t resrcToAddModListCount;
1244    SchPucchResrcInfo resrcToAddModList[MAX_NUM_PUCCH_RESRC];
1245    uint8_t resrcToRelListCount;
1246    uint8_t resrcToRelList[MAX_NUM_PUCCH_RESRC];
1247 }SchPucchResrcCfg;
1248
1249
1250 typedef struct schSchedReqResrcInfo
1251 {
1252    uint8_t resrcId;
1253    uint8_t requestId;
1254    uint8_t periodicity;
1255    uint16_t offset;
1256    uint8_t resrc;
1257 }SchSchedReqResrcInfo;
1258
1259 typedef struct schPucchSchedReqCfg
1260 {
1261    uint8_t           schedAddModListCount;
1262    SchSchedReqResrcInfo schedAddModList[MAX_NUM_SR_CFG_PER_CELL_GRP];
1263    uint8_t           schedRelListCount;
1264    uint8_t           schedRelList[MAX_NUM_SR_CFG_PER_CELL_GRP];
1265 }SchPucchSchedReqCfg;
1266
1267 typedef struct schSpatialRelationInfo
1268 {
1269    uint8_t spatialRelationId;
1270    uint8_t servCellIdx;
1271    uint8_t pathLossRefRSId;
1272    uint8_t p0PucchId;
1273    uint8_t closeLoopIdx;
1274 }SchSpatialRelationInfo;
1275
1276 typedef struct schPucchSpatialCfg
1277 {
1278    uint8_t spatialAddModListCount;
1279    SchSpatialRelationInfo spatialAddModList[MAX_NUM_SPATIAL_RELATIONS];
1280    uint8_t spatialRelListCount;
1281    uint8_t spatialRelList[MAX_NUM_SPATIAL_RELATIONS];
1282 }SchPucchSpatialCfg;
1283
1284 typedef struct schP0PucchCfg
1285 {
1286    uint8_t p0PucchId;
1287    int     p0PucchVal;
1288 }SchP0PucchCfg;
1289
1290 typedef struct schPathLossRefRSCfg
1291 {
1292    uint8_t pathLossRefRSId;
1293 }SchPathLossRefRSCfg;
1294
1295 typedef struct schPucchMultiCsiCfg
1296 {
1297    uint8_t  multiCsiResrcListCount;
1298    uint8_t  multiCsiResrcList[MAX_NUM_PUCCH_RESRC-1];
1299 }SchPucchMultiCsiCfg;
1300
1301 typedef struct schPucchDlDataToUlAck
1302 {
1303    uint8_t  dlDataToUlAckListCount;
1304    uint8_t  dlDataToUlAckList[MAX_NUM_DL_DATA_TO_UL_ACK];
1305 }SchPucchDlDataToUlAck;
1306
1307 typedef struct schPucchPowerControl
1308 {
1309    int deltaF_Format0;
1310    int deltaF_Format1;
1311    int deltaF_Format2;
1312    int deltaF_Format3;
1313    int deltaF_Format4;
1314    uint8_t p0SetCount;
1315    SchP0PucchCfg p0Set[MAX_NUM_PUCCH_P0_PER_SET];
1316    uint8_t pathLossRefRSListCount;
1317    SchPathLossRefRSCfg pathLossRefRSList[MAX_NUM_PATH_LOSS_REF_RS];
1318 }SchPucchPowerControl;
1319
1320 typedef struct schPucchCfg
1321 {
1322    SchPucchResrcSetCfg   *resrcSet;
1323    SchPucchResrcCfg      *resrc;
1324    SchPucchFormatCfg     *format1; 
1325    SchPucchFormatCfg     *format2; 
1326    SchPucchFormatCfg     *format3; 
1327    SchPucchFormatCfg     *format4;
1328    SchPucchSchedReqCfg   *schedReq;
1329    SchPucchMultiCsiCfg   *multiCsiCfg;
1330    SchPucchSpatialCfg    *spatialInfo;
1331    SchPucchDlDataToUlAck *dlDataToUlAck;
1332    SchPucchPowerControl  *powerControl;
1333 }SchPucchCfg;
1334
1335 /* Transform precoding disabled */
1336 typedef struct schTransPrecodDisabled
1337 {
1338    uint16_t   scramblingId0;
1339 }SchTransPrecodDisabled;
1340
1341 /* DMRS Uplink configuration */
1342 typedef struct SchDmrsUlCfg
1343 {
1344    SchDmrsAdditionPosition    addPos;               /* DMRS additional position */
1345    SchTransPrecodDisabled     transPrecodDisabled;  /* Transform precoding disabled */
1346 }SchDmrsUlCfg;
1347
1348 /* PUSCH Configuration */
1349 typedef struct schPuschCfg
1350 {
1351    uint8_t                    dataScramblingId;
1352    SchDmrsUlCfg               dmrsUlCfgForPuschMapTypeA;
1353    SchResourceAllocType       resourceAllocType;
1354    uint8_t                    numTimeDomRsrcAlloc;
1355    SchPuschTimeDomRsrcAlloc   timeDomRsrcAllocList[MAX_NUM_UL_ALLOC]; /* PUSCH time domain UL resource allocation list */
1356    SchTransformPrecoder       transformPrecoder;
1357 }SchPuschCfg;
1358
1359 /* Initial Uplink BWP */
1360 typedef struct schInitialUlBwp
1361 {
1362    bool          pucchCfgPres;
1363    SchPucchCfg   pucchCfg;
1364    bool          puschCfgPres;
1365    SchPuschCfg   puschCfg;
1366 }SchInitialUlBwp;
1367
1368 /* Uplink BWP information */
1369 typedef struct schUlBwpInfo
1370 {
1371    uint8_t        bwpId;
1372 }SchUlBwpInfo;
1373
1374 /* Serving cell configuration */
1375 typedef struct schServCellCfgInfo
1376 {
1377    SchInitalDlBwp        initDlBwp;
1378    uint8_t               numDlBwpToAdd;
1379    SchDlBwpInfo          DlBwpToAddList[MAX_NUM_BWP];
1380    uint8_t               firstActvDlBwpId;
1381    uint8_t               defaultDlBwpId;
1382    uint8_t               *bwpInactivityTmr;
1383    SchPdschServCellCfg   pdschServCellCfg;
1384    SchInitialUlBwp       initUlBwp;
1385    uint8_t               numUlBwpToAdd;
1386    SchUlBwpInfo          UlBwpToAddList[MAX_NUM_BWP];
1387    uint8_t               firstActvUlBwpId;
1388 }SchServCellCfgInfo;
1389
1390 typedef struct schNonDynFiveQi
1391 {
1392    uint16_t   fiveQi;
1393    uint8_t    priorLevel;
1394    uint16_t   avgWindow;
1395    uint16_t   maxDataBurstVol;
1396 }SchNonDynFiveQi;
1397
1398 typedef struct schDynFiveQi
1399 {
1400    uint8_t    priorLevel;
1401    uint16_t   packetDelayBudget;
1402    uint8_t    packetErrRateScalar;
1403    uint8_t    packetErrRateExp;
1404    uint16_t   fiveQi;
1405    uint8_t    delayCritical;
1406    uint16_t   avgWindow;
1407    uint16_t   maxDataBurstVol;
1408 }SchDynFiveQi;
1409
1410 typedef struct schNgRanAllocAndRetPri
1411 {
1412    uint8_t priorityLevel;
1413    uint8_t preEmptionCap;
1414    uint8_t preEmptionVul;
1415 }SchNgRanAllocAndRetPri;
1416
1417 typedef struct schGrbQosFlowInfo
1418 {
1419    uint32_t maxFlowBitRateDl;
1420    uint32_t maxFlowBitRateUl;
1421    uint32_t guarFlowBitRateDl;
1422    uint32_t guarFlowBitRateUl;
1423 }SchGrbQosFlowInfo;
1424
1425 /* DRB QoS */
1426 typedef struct schDrbQos
1427 {
1428    SchQosType  fiveQiType;   /* Dynamic or non-dynamic */ 
1429    union
1430    {
1431       SchNonDynFiveQi   nonDyn5Qi;
1432       SchDynFiveQi      dyn5Qi;
1433    }u;
1434    SchNgRanAllocAndRetPri  ngRanRetPri;
1435    SchGrbQosFlowInfo       grbQosFlowInfo;
1436    uint16_t                pduSessionId;
1437    uint32_t                ulPduSessAggMaxBitRate;   /* UL PDU Session Aggregate max bit rate */
1438 }SchDrbQosInfo;
1439
1440 typedef struct schSnssai
1441 {
1442    uint8_t   sst;
1443    uint8_t   sd[SD_SIZE];
1444 }SchSnssai;
1445
1446 /* Special cell configuration */
1447 typedef struct schSpCellCfg
1448 {
1449    uint8_t           servCellIdx;
1450    SchServCellCfgInfo   servCellCfg;
1451 }SchSpCellCfg;
1452
1453 /* Uplink logical channel configuration */
1454 typedef struct SchUlLcCfg
1455 {
1456    uint8_t priority;
1457    uint8_t lcGroup;
1458    uint8_t schReqId;
1459    uint8_t pbr;        // prioritisedBitRate
1460    uint8_t bsd;        // bucketSizeDuration
1461 }SchUlLcCfg;
1462
1463 /* Downlink logical channel configuration */
1464 typedef struct schDlLcCfg
1465 {
1466    uint8_t lcp;      // logical Channel Prioritization
1467 }SchDlLcCfg;
1468
1469 /* Logical Channel configuration */
1470 typedef struct schLcCfg
1471 {
1472    ConfigType     configType;
1473    uint8_t        lcId;
1474    SchDrbQosInfo  *drbQos;
1475    SchSnssai      *snssai;
1476    SchDlLcCfg     dlLcCfg;
1477    SchUlLcCfg     ulLcCfg;
1478 }SchLcCfg;
1479
1480 /* Aggregate max bit rate */
1481 typedef struct schAmbrCfg
1482 {
1483    uint32_t   ulBr;   /* Ul BitRate */
1484 }SchAmbrCfg;
1485
1486 typedef struct schModulationInfo
1487 {
1488    uint8_t      modOrder;
1489    uint8_t      mcsIndex;
1490    SchMcsTable  mcsTable;
1491 }SchModulationInfo;
1492
1493 /* UE configuration */
1494 typedef struct schUeCfg
1495 {
1496    uint16_t        cellId;
1497    uint16_t        crnti;
1498    bool macCellGrpCfgPres;
1499    SchMacCellGrpCfg   macCellGrpCfg;
1500    bool phyCellGrpCfgPres;
1501    SchPhyCellGrpCfg   phyCellGrpCfg;
1502    bool spCellCfgPres;
1503    SchSpCellCfg       spCellCfg;
1504    SchAmbrCfg         *ambrCfg;
1505    SchModulationInfo  dlModInfo;
1506    SchModulationInfo  ulModInfo;
1507    uint8_t            numLcs;
1508    SchLcCfg           schLcCfg[MAX_NUM_LC];
1509 }SchUeCfg;
1510
1511 typedef struct schUeCfgRsp
1512 {
1513    uint16_t   ueIdx;
1514    uint16_t   cellId;
1515    uint16_t   crnti;
1516    SchMacRsp  rsp;
1517    SchFailureCause cause;
1518 }SchUeCfgRsp;
1519
1520 typedef struct schUeDelete
1521 {
1522    uint16_t   cellId;
1523    uint16_t   crnti;
1524 }SchUeDelete;
1525
1526 typedef struct schUeDeleteRsp
1527 {
1528    uint16_t   cellId;
1529    uint16_t   crnti;
1530    SchMacRsp  rsp;
1531    ErrorCause cause;
1532 }SchUeDeleteRsp;
1533
1534 typedef struct schCellDelete 
1535 {
1536    uint16_t   cellId;
1537 }SchCellDelete;
1538
1539
1540 typedef struct schCellDeleteRsp
1541 {
1542    uint16_t   cellId;
1543    SchMacRsp  rsp;
1544 }SchCellDeleteRsp;
1545
1546 typedef struct dataVolInfo
1547 {
1548    uint8_t  lcgId;
1549    uint32_t dataVol;
1550 }DataVolInfo;
1551
1552 typedef struct ulBufferStatusRptInd
1553 {
1554    uint16_t    cellId;
1555    uint16_t    crnti;
1556    BsrType     bsrType;
1557    uint8_t     numLcg;
1558    DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS];
1559 }UlBufferStatusRptInd;
1560
1561 typedef struct srUciIndInfo
1562 {
1563    uint16_t    cellId;
1564    uint16_t    crnti;
1565    SlotTimingInfo slotInd;
1566    uint8_t     numSrBits;
1567    uint8_t     srPayload[MAX_SR_BITS_IN_BYTES];
1568 }SrUciIndInfo;
1569
1570 /* function pointers */
1571
1572 typedef uint8_t (*SchCellCfgCfmFunc)    ARGS((
1573          Pst            *pst,           /* Post Structure */                         
1574          SchCellCfgCfm  *schCellCfgCfm  /* Cell Cfg Cfm */
1575          ));
1576
1577 typedef uint8_t (*SchCellCfgFunc)    ARGS((
1578          Pst         *pst,           /* Post Structure */                         
1579          SchCellCfg  *schCellCfg     /* Cell Cfg  */
1580          ));
1581
1582 typedef uint8_t (*SchMacDlAllocFunc)     ARGS((                     
1583          Pst            *pst,          /* Post Structure */                         
1584          DlSchedInfo    *dlSchedInfo   /* dl allocation Info */                      
1585          ));
1586
1587 typedef uint8_t (*SchMacUlSchInfoFunc)     ARGS((                     
1588          Pst         *pst,           /* Post Structure */                         
1589          UlSchedInfo *ulSchedInfo    /* UL Alloc Sch  Info */                      
1590          ));
1591
1592 typedef uint8_t (*MacSchRachIndFunc) ARGS((
1593          Pst         *pst,         /* Post structure */
1594          RachIndInfo *rachInd));    /* Rach Indication Info */
1595
1596 typedef uint8_t (*MacSchCrcIndFunc) ARGS(( 
1597          Pst         *pst,         /* Post structure */
1598          CrcIndInfo  *crcInd));     /* CRC Info */
1599
1600 typedef uint8_t (*MacSchDlRlcBoInfoFunc) ARGS((
1601          Pst         *pst,         /* Post structure */
1602          DlRlcBoInfo *dlBoInfo));   /* DL BO Info */
1603
1604 typedef uint8_t (*MacSchAddUeConfigReqFunc) ARGS((
1605          Pst         *pst,           /* Post structure */
1606          SchUeCfg    *ueCfgToSch));   /* Scheduler UE Cfg */
1607
1608 typedef uint8_t (*SchUeCfgRspFunc) ARGS((
1609          Pst         *pst,           /* Post structure */
1610          SchUeCfgRsp *cfgRsp));       /* Scheduler UE Cfg response */
1611
1612 typedef uint8_t (*MacSchSlotIndFunc) ARGS((
1613          Pst         *pst,          /* Post structure */
1614          SlotTimingInfo *slotInd));    /* Slot Info */
1615
1616 typedef uint8_t (*MacSchBsrFunc)       ARGS((
1617    Pst                  *pst,
1618    UlBufferStatusRptInd *bsrInd
1619 ));
1620
1621 typedef uint8_t (*MacSchSrUciIndFunc) ARGS(( 
1622          Pst         *pst,         /* Post structure */
1623          SrUciIndInfo  *uciInd));    /* UCI IND Info */
1624
1625 typedef uint8_t (*MacSchModUeConfigReqFunc) ARGS((
1626          Pst         *pst,           /* Post structure */
1627          SchUeCfg    *ueCfgToSch));   /* Scheduler UE Cfg */
1628
1629 typedef uint8_t (*SchUeReCfgRspFunc) ARGS((
1630          Pst         *pst,           /* Post structure */
1631          SchUeCfgRsp *cfgRsp));       /* Scheduler UE Cfg response */
1632
1633 typedef uint8_t (*MacSchUeDeleteReqFunc) ARGS((
1634    Pst         *pst,           /* Post structure */
1635    SchUeDelete *schUeDel)); /*Scheduler UE Del*/
1636
1637 typedef uint8_t (*SchUeDeleteRspFunc) ARGS((
1638    Pst          *pst,           /* Post structure */
1639    SchUeDeleteRsp *delRsp));       /* Scheduler UE delete response */
1640
1641 typedef uint8_t (*MacSchCellDeleteReqFunc) ARGS((
1642    Pst         *pst,           /* Post structure */
1643    SchCellDelete *schCellDelete)); /*Scheduler UE Del*/
1644
1645 typedef uint8_t (*SchCellDeleteRspFunc) ARGS((
1646    Pst          *pst,           /* Post structure */
1647    SchCellDeleteRsp *schCellDeleteRsp));       /* Scheduler UE delete response */
1648
1649 /* function declarations */
1650 uint8_t packMacSchSlotInd(Pst *pst, SlotTimingInfo *slotInd);
1651 uint8_t packSchMacDlAlloc(Pst *pst, DlSchedInfo  *dlSchedInfo);
1652 uint8_t packSchMacUlSchInfo(Pst *pst, UlSchedInfo *ulSchedInfo);
1653 uint8_t packSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
1654 uint8_t packSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
1655 uint8_t MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo);
1656 uint8_t MacProcSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
1657 uint8_t MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
1658 uint8_t SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg);
1659 uint8_t schActvInit(Ent entity, Inst instId, Region region, Reason reason);
1660 uint8_t MacProcUlSchInfo(Pst *pst, UlSchedInfo *ulSchedInfo);
1661 uint8_t packMacSchRachInd(Pst *pst, RachIndInfo *rachInd);
1662 uint8_t MacSchRachInd(Pst *pst, RachIndInfo *rachInd);
1663 uint8_t packMacSchCrcInd(Pst *pst, CrcIndInfo *crcInd);
1664 uint8_t MacSchCrcInd(Pst *pst, CrcIndInfo *crcInd);
1665 uint8_t packMacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo);
1666 uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo);
1667 uint8_t packMacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfgToSch);
1668 uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfgToSch);
1669 uint8_t packSchUeCfgRsp(Pst *pst, SchUeCfgRsp *cfgRsp);
1670 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *cfgRsp);
1671 uint8_t MacSchSlotInd ARGS((Pst * pst, SlotTimingInfo * slotInd));
1672 uint8_t packMacSchSlotInd(Pst * pst, SlotTimingInfo * slotInd);
1673 uint8_t unpackMacSchSlotInd(MacSchSlotIndFunc func, Pst *pst, Buffer  *mBuf);
1674 uint8_t packMacSchBsr(Pst *pst, UlBufferStatusRptInd *bsrInd);
1675 uint8_t MacSchBsr(Pst *pst, UlBufferStatusRptInd *bsrInd);
1676 uint8_t packMacSchSrUciInd(Pst *pst, SrUciIndInfo *uciInd);
1677 uint8_t MacSchSrUciInd(Pst *pst, SrUciIndInfo *uciInd);
1678 uint8_t packMacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfgToSch);
1679 uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfgToSch);
1680 uint8_t packSchUeReconfigRsp(Pst *pst, SchUeCfgRsp *cfgRsp);
1681 uint8_t MacProcSchUeReconfigRsp(Pst *pst, SchUeCfgRsp *cfgRsp);
1682 uint8_t packMacSchUeDeleteReq(Pst *pst,  SchUeDelete *schUeDel);
1683 uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete  *ueDelete);
1684 uint8_t packSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp  *delRsp);
1685 uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp);
1686 uint8_t packMacSchCellDeleteReq(Pst *pst,  SchCellDelete *schCellDelete);
1687 uint8_t MacSchCellDeleteReq(Pst *pst, SchCellDelete  *schCellDelete);
1688 uint8_t packSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp  *schCellDeleteRsp);
1689 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDeleteRsp);
1690
1691 /**********************************************************************
1692   End of file
1693  **********************************************************************/
1694