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