Ue Create Request from DU_APP to MAC
[o-du/l2.git] / src / cm / du_app_mac_inf.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 /* Defines APIs exchanged between du_app and cl module of MAC */
20 #ifndef __MACINT_H__
21 #define __MACINT_H__
22
23 #include <stdbool.h>
24
25 #define NUM_NUMEROLOGY 5  /* Number of numerology */
26 #define MAXIMUM_TDD_PERIODICITY 5
27 #define MAX_SYMB_PER_SLOT 14 
28
29 #define NUM_SSB         1       /* max value is 64 */
30 #define SSB_MASK_SIZE   1       /* SSB mask size is 32bit for sub6 */
31 #define SIB1_NEW_TX_PERIOD      160
32 #define SIB1_REPETITION_PERIOD   20
33 #define CORESET_0_INDEX      0
34 #define CORESET_1_INDEX      1
35 #define CORESET_2_INDEX      2
36 #define CORESET_3_INDEX      3
37 #define CORESET_4_INDEX      4
38 #define SEARCHSPACE_0_INDEX   0
39 #define SEARCHSPACE_1_INDEX   1
40 #define SEARCHSPACE_2_INDEX   2
41 #define SEARCHSPACE_3_INDEX   3
42 #define SEARCHSPACE_4_INDEX   4
43 #define SS_MONITORING_SLOT_SL1   0 /* all slots */
44 #define SS_MONITORING_SYMBOL     0x2000; /* symbol-0, set 14th bit */
45 #define SIB1_MCS  4
46
47 #define SRB_ID_0 0
48 #define SRB_ID_1 1
49 /* Macro for Ue Context */
50 #define MAX_NUM_LOGICAL_CHANNELS 11
51 #define MAX_NUM_SR_CFG_PER_CELL_GRP 8   /* Max number of scheduling request config per cell group */
52 #define MAC_NUM_TAGS 4                  /* Max number of timing advance groups */
53 #define MAX_NUM_BWP  4                  /* Max number of BWP per serving cell */
54 #define MAX_NUM_CRSET  3                /* Max number of control resource set in add/modify/release list */
55 #define MAX_NUM_SEARCH_SPC  10          /* Max number of search space in add/modify/release list */
56 #define FREQ_DOM_RSRC_SIZE  6           /* i.e. 6 bytes because Size of frequency domain resource is 45 bits */
57 #define MONITORING_SYMB_WITHIN_SLOT_SIZE 2  /* i.e. 2 bytes because size of monitoring symbols within slot is 14 bits */
58 #define MAX_NUM_DL_ALLOC 16             /* Max number of pdsch time domain downlink allocation */
59 #define MAX_NUM_UL_ALLOC 16             /* Max number of pusch time domain uplink allocation */
60 #define SD_SIZE   3                     /* Max size of Slice Differentiator in S-NSSAI */
61 #define PDSCH_START_SYMBOL_LEN 53
62 #define PUSCH_START_SYMBOL_LEN 41
63
64 /* Macros for coupling */
65 #define DU_MAC_LC  0
66 #define DU_MAC_TC  1
67 #define DU_MAC_LWLC  2
68
69 /* Event IDs */
70 #define EVENT_MAC_CELL_CONFIG_REQ    200
71 #define EVENT_MAC_CELL_CONFIG_CFM    201
72 #define EVENT_MAC_CELL_START_REQ     202
73 #define EVENT_MAC_CELL_STOP_REQ      203
74 #define EVENT_MAC_SLOT_IND           204
75 #define EVENT_MAC_STOP_IND           205
76 #define EVENT_MAC_UL_CCCH_IND        206
77 #define EVENT_MAC_DL_CCCH_IND        207
78 #define EVENT_MAC_UE_CREATE_REQ      208
79
80 typedef enum
81 {
82    DUP_MODE_FDD,
83    DUP_MODE_TDD
84 }DuplexMode;
85
86 typedef enum
87 {
88    MAC_GEN_FULL_PBCH_PAYLD,   /* MAC generated the full PBCH Payload */
89    PHY_GEN_TIMING_PBCH_BIT,   /* PHY generates the timing PBCH bits */
90    PHY_GEN_FULL_PBCH_PAYLD    /* PHY generates full PBCH payload */
91 }BchPduOpt;
92
93 typedef enum
94 {
95    LONG_SEQUENCE,
96    SHORT_SEQUENCE
97 }PrachSeqLen;
98
99 typedef enum
100 {
101    UNRESTRICTED,
102    RESTRICTED_SET_TYPE_A,
103    RESTRICTED_SET_TYPE_B
104 }RstSetCfg;
105
106 typedef enum
107 {
108    DONT_REPORT_RSSI,
109    RSSI_UNIT_DBM,
110    RSSI_UNIT_DBFS
111 }RSSIMeasUnit;
112
113 typedef enum
114 {
115    DL_SLOT,
116    UL_SLOT,
117    GUARD_SLOT
118 }SlotConfig;
119
120 typedef enum
121 {
122    TX_PRDCTY_MS_0P5,
123    TX_PRDCTY_MS_0P625,
124    TX_PRDCTY_MS_1,
125    TX_PRDCTY_MS_1P25,
126    TX_PRDCTY_MS_2,
127    TX_PRDCTY_MS_2P5,
128    TX_PRDCTY_MS_5,
129    TX_PRDCTY_MS_10
130 }DlUlTxPeriodicity;
131
132 typedef enum
133 {
134    BETA_PSS_0DB,
135    BETA_PSS_1DB
136 }BetaPss;
137
138 typedef enum 
139 {
140    SSB_PRDCTY_MS_5,
141    SSB_PRDCTY_MS_10,
142    SSB_PRDCTY_MS_20,
143    SSB_PRDCTY_MS_40,
144    SSB_PRDCTY_MS_80,
145    SSB_PRDCTY_MS_160
146 }SSBPeriod;
147
148 typedef enum
149 {
150    RRC_REJECT,
151    RRC_SETUP
152 }DlCcchMsgType;
153
154 /* Enums for Ue Create Request */
155
156 /* SR PROHIBIT TIMER */
157 typedef enum
158 {
159    SR_PROHIBIT_MS_1,
160    SR_PROHIBIT_MS_2,
161    SR_PROHIBIT_MS_4,
162    SR_PROHIBIT_MS_8,
163    SR_PROHIBIT_MS_16,
164    SR_PROHIBIT_MS_32,
165    SR_PROHIBIT_MS_64,
166    SR_PROHIBIT_MS_128
167 }SrProhibitTimer;
168
169 typedef enum
170 {
171    SR_TRANS_MAX_N_4,
172    SR_TRANS_MAX_N_8,
173    SR_TRANS_MAX_N_16,
174    SR_TRANS_MAX_N_32,
175    SR_TRANS_MAX_N_64,
176    SR_TRANS_MAX_spare3,
177    SR_TRANS_MAX_spare2,
178    SR_TRANS_MAX_spare1
179 }SrTransMax;
180
181 typedef enum
182 {
183    TIME_ALIGNMENT_TIMER_MS_500,
184    TIME_ALIGNMENT_TIMER_MS_750,
185    TIME_ALIGNMENT_TIMER_MS_1280,
186    TIME_ALIGNMENT_TIMER_MS_1920,
187    TIME_ALIGNMENT_TIMER_MS_2560,
188    TIME_ALIGNMENT_TIMER_MS_5120,
189    TIME_ALIGNMENT_TIMER_MS_10240,
190    TIME_ALIGNMENT_TIMER_INFINITY
191 }TimeAlignmentTimer;
192
193 typedef enum
194 {
195    PHR_PERIODIC_TIMER_SF_10,
196    PHR_PERIODIC_TIMER_SF_20,
197    PHR_PERIODIC_TIMER_SF_50,
198    PHR_PERIODIC_TIMER_SF_100,
199    PHR_PERIODIC_TIMER_SF_200,
200    PHR_PERIODIC_TIMER_SF_500,
201    PHR_PERIODIC_TIMER_SF_1000,
202    PHR_PERIODIC_TIMER_INFINITY
203 }PhrPeriodicTimer;
204
205 typedef enum
206 {
207    PHR_PROHIBIT_TIMER_SF_0,
208    PHR_PROHIBIT_TIMER_SF_10,
209    PHR_PROHIBIT_TIMER_SF_20,
210    PHR_PROHIBIT_TIMER_SF_50,
211    PHR_PROHIBIT_TIMER_SF_100,
212    PHR_PROHIBIT_TIMER_SF_200,
213    PHR_PROHIBIT_TIMER_SF_500,
214    PHR_PROHIBIT_TIMER_SF_1000
215 }PhrProhibitTimer;
216
217 typedef enum
218 {
219    PHR_TX_PWR_FACTOR_CHANGE_DB_1,
220    PHR_TX_PWR_FACTOR_CHANGE_DB_3,
221    PHR_TX_PWR_FACTOR_CHANGE_DB_6,
222    PHR_TX_PWR_FACTOR_CHANGE_INFINITY
223 }PhrTxPwrFactorChange;
224
225 typedef enum
226 {
227    PHR_MODE_OTHER_CG_REAL,
228    PHR_MODE_OTHER_CG_VIRTUAL
229 }PhrModeOtherCG;
230
231 typedef enum
232 {
233    PDSCH_HARQ_ACK_CODEBOOK_SEMISTATIC,
234    PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC
235 }PdschHarqAckCodebook;
236
237 typedef enum
238 {
239    NUM_HARQ_PROC_FOR_PDSCH_N_2,
240    NUM_HARQ_PROC_FOR_PDSCH_N_4,
241    NUM_HARQ_PROC_FOR_PDSCH_N_6,
242    NUM_HARQ_PROC_FOR_PDSCH_N_10,
243    NUM_HARQ_PROC_FOR_PDSCH_N_16
244 }NumHarqProcForPdsch;
245
246 typedef enum
247 {
248    MAX_CODE_BLOCK_GROUP_PER_TB_N_2,
249    MAX_CODE_BLOCK_GROUP_PER_TB_N_4,
250    MAX_CODE_BLOCK_GROUP_PER_TB_N_6,
251    MAX_CODE_BLOCK_GROUP_PER_TB_N_8
252 }MaxCodeBlkGrpPerTB;
253
254 typedef enum
255 {
256    PDSCH_X_OVERHEAD_6,
257         PDSCH_X_OVERHEAD_12,
258         PDSCH_X_OVERHEAD_18
259 }PdschXOverhead;
260
261 typedef enum
262 {
263    TRANSFORM_PRECODER_ENABLED,
264    TRANSFORM_PRECODER_DISABLED
265 }TransformPrecoder;
266
267 typedef enum 
268 {
269    CCE_REG_MAPPINGTYPE_PR_INTERLEAVED,
270    CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED
271 }REGMappingType;
272
273 typedef enum
274 {
275    SLOTPERIODICITYANDOFFSET_PR_SL1,
276    SLOTPERIODICITYANDOFFSET_PR_SL2,
277    SLOTPERIODICITYANDOFFSET_PR_SL4,
278    SLOTPERIODICITYANDOFFSET_PR_SL5,
279    SLOTPERIODICITYANDOFFSET_PR_SL8,
280    SLOTPERIODICITYANDOFFSET_PR_SL10,
281    SLOTPERIODICITYANDOFFSET_PR_SL16,
282    SLOTPERIODICITYANDOFFSET_PR_SL20,
283    SLOTPERIODICITYANDOFFSET_PR_SL40,
284    SLOTPERIODICITYANDOFFSET_PR_SL80,
285    SLOTPERIODICITYANDOFFSET_PR_SL160,
286    SLOTPERIODICITYANDOFFSET_PR_SL320,
287    SLOTPERIODICITYANDOFFSET_PR_SL640,
288    SLOTPERIODICITYANDOFFSET_PR_SL1280,
289    SLOTPERIODICITYANDOFFSET_PR_SL2560
290 }MSlotPeriodAndOffset;
291
292 typedef enum
293 {
294   SAMEASREG_BUNDLE,
295   ALL_CONTIGUOUS_RBS
296 }PrecoderGranul;
297
298 typedef enum
299 {
300    SEARCHSPACETYPE_PR_COMMON,
301    SEARCHSPACETYPE_PR_UE_SPECIFIC
302 }SearchSpaceType;
303
304 typedef enum
305 {
306    AGGREGATIONLEVEL_N0  = 0,  
307    AGGREGATIONLEVEL_N1  = 1,
308    AGGREGATIONLEVEL_N2  = 2,
309    AGGREGATIONLEVEL_N3  = 3,
310    AGGREGATIONLEVEL_N4  = 4,
311    AGGREGATIONLEVEL_N5  = 5,
312    AGGREGATIONLEVEL_N6  = 6,
313    AGGREGATIONLEVEL_N8  = 7
314 }AggrLevel;
315
316 typedef enum
317 {
318    ADDITIONALPOSITION_POS0,
319    ADDITIONALPOSITION_POS1,
320    ADDITIONALPOSITION_POS3
321 }AddPosType;
322
323 typedef enum
324 {
325    MAPPING_TYPEA,
326    MAPPING_TYPEB
327 }CommonMappingType;
328
329 typedef enum
330 {
331    RESOURCEALLOCATION_TYPE0,
332    RESOURCEALLOCATION_TYPE1,
333    RESOURCEALLOCATION_DYNAMICSWITCH
334 }ResAllocType;
335
336 typedef enum
337 {
338    RBG_SIZE_CONFIG1,
339    RBG_SIZE_CONFIG2
340 }RBGSize;
341
342 typedef enum
343 {
344    CODEWORDS_SCHED_BY_DCI_N1,
345    CODEWORDS_SCHED_BY_DCI_N2
346 }CodeWordsSchedDci;
347
348 typedef enum
349 {
350    TYPE_STATIC_BUNDLING,
351    TYPE_DYNAMIC_BUNDLING
352 }BundlingType;
353
354 typedef enum
355 {
356   LC_PRIORITY_1 = 1,
357   LC_PRIORITY_2,
358   LC_PRIORITY_3
359 }LcPriority;
360
361 typedef struct carrierCfg
362 {
363    Bool  pres;
364    U16   bw;             /* DL/UL bandwidth */
365    U32   freq;           /* Absolute frequency of DL/UL point A in KHz */
366    U16   k0[NUM_NUMEROLOGY];          /* K0 for DL/UL */
367    U16   gridSize[NUM_NUMEROLOGY];    /* DL/UL Grid size for each numerologies */
368    U16   numAnt;         /* Number of Tx/Rx antennas */
369 }CarrierCfg;
370
371 typedef struct ssbCfg
372 {
373    uint32_t    ssbPbchPwr;       /* SSB block power */
374    BchPduOpt   bchPayloadFlag;   /* Options for generation of payload */
375    uint8_t     scsCmn;           /* subcarrier spacing for common */
376    uint16_t    ssbOffsetPointA;  /* SSB subcarrier offset from point A */
377    BetaPss     betaPss;
378    SSBPeriod   ssbPeriod;        /* SSB Periodicity in msec */
379    uint8_t     ssbScOffset;       /* Subcarrier Offset */
380    uint8_t     mibPdu[3];           /* MIB payload */
381    uint32_t    ssbMask[SSB_MASK_SIZE];      /* Bitmap for actually transmitted SSB. */
382    uint8_t     beamId[NUM_SSB];
383    Bool        multCarrBand;     /* Multiple carriers in a band */
384    Bool        multCellCarr;     /* Multiple cells in single carrier */
385 }SsbCfg;
386
387 typedef struct fdmInfo
388 {
389    U16   rootSeqIdx;        /* Root sequence index */
390    U8    numRootSeq;        /* Number of root sequences required for FD */
391    U16   k1;                /* Frequency Offset for each FD */
392    U8    zeroCorrZoneCfg;   /* Zero correlation zone cofig */
393    U8    numUnusedRootSeq;  /* Number of unused root sequence */
394    U8    *unsuedRootSeq;     /* Unused root sequence per FD */
395 }PrachFdmInfo;
396
397 typedef struct prachCfg
398 {
399    Bool          pres;
400         uint8_t       prachCfgIdx;         /* PRACH Cfg Index */
401    PrachSeqLen   prachSeqLen;         /* RACH Sequence length: Long/short */
402    uint8_t       prachSubcSpacing;    /* Subcarrier spacing of RACH */
403    RstSetCfg     prachRstSetCfg;      /* PRACH restricted set config */
404         uint16_t      msg1FreqStart;       /* Msg1-FrequencyStart */
405    uint8_t       msg1Fdm;             /* PRACH FDM (1,2,4,8) */
406         uint8_t       rootSeqLen;          /* Root sequence length */
407    PrachFdmInfo  fdm[8];              /* FDM info */
408    uint8_t       ssbPerRach;          /* SSB per RACH occassion */
409    Bool          prachMultCarrBand;   /* Multiple carriers in Band */
410    uint8_t       prachRestrictedSet; /* Support for PRACH restricted set */
411         uint8_t       raContResTmr;        /* RA Contention Resoultion Timer */
412         uint8_t       rsrpThreshSsb;       /* RSRP Threshold SSB */
413    uint8_t       raRspWindow;         /* RA Response Window */
414 }PrachCfg;
415
416 typedef struct tddCfg
417 {
418    Bool               pres;
419    DlUlTxPeriodicity  tddPeriod;      /* DL UL Transmission periodicity */
420    SlotConfig         slotCfg[MAXIMUM_TDD_PERIODICITY][MAX_SYMB_PER_SLOT]; 
421 }TDDCfg;
422
423 typedef struct sib1CellCfg
424 {
425    uint8_t  *sib1Pdu;
426    uint16_t sib1PduLen;
427    uint16_t sib1NewTxPeriod;
428    uint16_t sib1RepetitionPeriod;
429    uint8_t coresetZeroIndex;     /* derived from 4 LSB of pdcchSib1 present in MIB */
430    uint8_t searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */
431    uint16_t sib1Mcs;
432 } Sib1CellCfg; 
433
434 typedef struct bwpParams
435 {
436    uint16_t firstPrb;
437    uint16_t numPrb;
438         uint8_t  scs;
439         uint8_t  cyclicPrefix;
440 }BwpParams;
441
442 typedef struct candidatesInfo
443 {
444    uint8_t aggLevel1;
445    uint8_t aggLevel2;
446    uint8_t aggLevel4;
447    uint8_t aggLevel8;
448    uint8_t aggLevel16;
449 }CandidatesInfo;
450
451 typedef struct searchSpaceCfg
452 {
453    uint8_t searchSpaceId;
454         uint8_t coresetId;
455         uint16_t monitoringSlot;
456         uint16_t duration;
457         uint16_t monitoringSymbol;
458         CandidatesInfo candidate;
459 }SearchSpaceCfg;
460
461 typedef struct pdcchConfigCommon
462 {
463    /* only one search space is configured during SIB1 */
464    SearchSpaceCfg commonSearchSpace;
465    uint8_t raSearchSpaceId;
466 }PdcchConfigCommon;
467
468 typedef struct pdschConfigCommon
469 {
470    uint8_t k0;
471         uint8_t mappingType;
472         uint8_t startSymbol;
473         uint8_t lengthSymbol;
474 }PdschConfigCommon;
475
476 typedef struct pucchConfigCommon
477 {
478    uint8_t pucchResourceCommon;
479         uint8_t pucchGroupHopping;
480 }PucchConfigCommon;
481
482 typedef struct puschConfigCommon
483 {
484    /* PUSCH-TimeDomainResourceAllocation info */
485    uint8_t k2;
486         uint8_t mappingType;
487         uint8_t startSymbol;
488         uint8_t lengthSymbol;
489 }PuschConfigCommon;
490
491 typedef struct bwpDlConfig
492 {
493    BwpParams      bwp;
494         PdcchConfigCommon pdcchCommon;
495         PdschConfigCommon pdschCommon;
496 }BwpDlConfig;
497
498 typedef struct bwpUlConfig
499 {
500    BwpParams      bwp;
501         // rach config common sent in PrachCfg
502         PucchConfigCommon pucchCommon;
503         PuschConfigCommon puschCommon;
504 }BwpUlConfig;
505
506 typedef struct macCellCfg
507 {
508         U16            transId;          /* Trans Id */
509         U16            cellId;           /* Cell Id */
510         U8             numTlv;           /* Number of configuration TLVs */
511         U8             carrierId;        /* Carrired Index */
512         U16            phyCellId;        /* Physical cell id */
513         DuplexMode     dupType;          /* Duplex type: TDD/FDD */
514         CarrierCfg     dlCarrCfg;        /* DL Carrier configuration */
515         CarrierCfg     ulCarrCfg;        /* UL Carrier configuration */
516         Bool           freqShft;         /* Indicates presence of 7.5kHz frequency shift */
517    SsbCfg         ssbCfg;           /* SSB configuration */          
518    PrachCfg       prachCfg;         /* PRACH Configuration */
519    TDDCfg         tddCfg;           /* TDD periodicity and slot configuration */
520    RSSIMeasUnit   rssiUnit;         /* RSSI measurement unit */
521    Sib1CellCfg    sib1Cfg;          /* SIB1 config */
522         BwpDlConfig    initialDlBwp;     /* Initial DL BWP */
523         BwpUlConfig    initialUlBwp;     /* Initial UL BWP */
524         uint8_t        dmrsTypeAPos;     /* DMRS Type A position */
525 }MacCellCfg;
526
527 typedef struct macCellCfgCfm
528 {
529         uint8_t        rsp; 
530    U16            transId;
531 }MacCellCfgCfm;
532
533 typedef struct slotInfo
534 {
535    uint16_t cellId;
536    uint16_t sfn;
537    uint16_t slot;
538 }SlotInfo;
539
540 typedef struct macCellStartInfo
541 {
542    uint16_t cellId;
543 }MacCellStartInfo;
544
545 typedef struct macCellStopInfo
546 {
547    uint16_t cellId;
548 }MacCellStopInfo;
549
550 typedef struct ulCcchInd
551 {
552    uint16_t cellId;
553    uint16_t crnti;
554    uint8_t  *ulCcchMsg;
555 }UlCcchIndInfo;
556
557 typedef struct dlCcchInd
558 {
559    uint16_t      cellId;
560    uint16_t      crnti;
561    DlCcchMsgType msgType;
562    uint16_t      dlCcchMsgLen;
563    uint8_t       *dlCcchMsg;
564 }DlCcchIndInfo;
565
566 typedef struct bsrCfg
567 {
568    uint8_t periodicTimer;
569    uint8_t retxTimer;
570    uint8_t srDelayTimer;
571 }BsrCfg;
572
573
574 /* Info of Scheduling Request to Add/Modify */
575 typedef struct schedReqInfo
576 {
577    uint8_t         schedReqId;
578    SrProhibitTimer srProhibitTmr;
579    SrTransMax      srTransMax;
580 }SchedReqInfo;
581
582 /* Scheduling Request Configuration */
583 typedef struct schedReqCfg
584 {
585    uint8_t       addModListCount;
586    SchedReqInfo  addModList[MAX_NUM_SR_CFG_PER_CELL_GRP];   /* List of Scheduling req to be added/modified */
587    uint8_t       relListCount;
588    uint8_t       relList[MAX_NUM_SR_CFG_PER_CELL_GRP];      /* list of scheduling request Id to be deleted */
589 }SchedReqCfg;
590
591 typedef struct tagInfo
592 {
593    uint8_t tagId;
594    TimeAlignmentTimer timeAlignTimer;
595 }TagInfo;
596
597 typedef struct tagCfg
598 {
599    uint8_t      addModListCount;
600    TagInfo      addModList[MAC_NUM_TAGS];  /* List of Tag to Add/Modify */
601    uint8_t      relListCount;
602    uint8_t      relList[MAC_NUM_TAGS];     /* list of Tag Id to release */
603 }TagCfg;
604
605 typedef struct phrCfg
606 {
607    PhrPeriodicTimer periodicTimer;
608    PhrProhibitTimer prohibitTimer; 
609    PhrTxPwrFactorChange txPowerFactor;
610    bool     multiplePHR;       
611    bool     dummy;
612    bool     phrType2OtherCell;
613    PhrModeOtherCG phrOtherCG;
614 }PhrCfg;
615
616 typedef struct macCellGrpCfg
617 {
618    SchedReqCfg schReqCfg;
619    TagCfg tagCfg;
620    //BsrCfg bsrCfg;
621    bool   phrCfgSetupPres;   /* true/false: phrCfgSetup/phrCfgRelease */
622    PhrCfg phrCfg;
623 }MacCellGrpCfg;
624
625 typedef struct phyCellGrpCfg
626 {
627    PdschHarqAckCodebook  pdschHarqAckCodebook;
628    uint8_t    pNrFr1;
629 }PhyCellGrpCfg;
630
631 /* Control resource set info */
632 typedef struct controlRsrcSet
633 {
634    uint8_t     cRSetId;                /* Control resource set id */
635    uint8_t     freqDomainRsrc[FREQ_DOM_RSRC_SIZE];  /* Frequency domain resource */
636    uint8_t     duration;
637    REGMappingType cceRegMappingType;
638    PrecoderGranul precoderGranularity;
639    uint16_t    dmrsScramblingId;
640 }ControlRsrcSet;
641
642 /* Search Space info */
643 typedef struct searchSpace
644 {
645    uint8_t     searchSpaceId;
646    uint8_t     cRSetId;
647    MSlotPeriodAndOffset  mSlotPeriodicityAndOffset;
648    uint8_t     mSymbolsWithinSlot[MONITORING_SYMB_WITHIN_SLOT_SIZE];
649    AggrLevel   numCandidatesAggLevel1;      /* Number of candidates for aggregation level 1 */
650    AggrLevel   numCandidatesAggLevel2;      /* Number of candidates for aggregation level 2 */
651    AggrLevel   numCandidatesAggLevel4;      /* Number of candidates for aggregation level 4 */
652    AggrLevel   numCandidatesAggLevel8;      /* Number of candidates for aggregation level 8 */
653    AggrLevel   numCandidatesAggLevel16;     /* Number of candidates for aggregation level 16 */
654    SearchSpaceType searchSpaceType;
655    uint8_t     ueSpecificDciFormat;
656 }SearchSpace;
657
658 /* PDCCH cofniguration */
659 typedef struct pdcchConfig
660 {
661    uint8_t           numCRsetToAddMod;
662    ControlRsrcSet    cRSetToAddModList[MAX_NUM_CRSET];           /* List of control resource set to add/modify */
663    uint8_t           numCRsetToRel;
664    uint8_t           cRSetToRelList[MAX_NUM_CRSET];              /* List of control resource set to release */
665    uint8_t           numSearchSpcToAddMod;
666    SearchSpace       searchSpcToAddModList[MAX_NUM_SEARCH_SPC];  /* List of search space to add/modify */
667    uint8_t           numSearchSpcToRel;
668    uint8_t           searchSpcToRelList[MAX_NUM_SEARCH_SPC];     /* List of search space to release */
669 }PdcchConfig;
670
671 /* PDSCH time domain resource allocation */
672 typedef struct pdschTimeDomRsrcAlloc
673 {
674    CommonMappingType mappingType;
675    uint8_t           startSymbolAndLength;
676 }PdschTimeDomRsrcAlloc;
677
678 /* DMRS downlink configuration */
679 typedef struct dmrsDlCfg
680 {
681    AddPosType  addPos;       /* DMRS additional position */
682 }DmrsDlCfg;
683
684 /* PDSCH Configuration */
685 typedef struct pdschConfig
686 {
687    DmrsDlCfg               dmrsDlCfgForPdschMapTypeA;
688    ResAllocType            resourceAllocType;
689    uint8_t                 numTimeDomRsrcAlloc;
690    PdschTimeDomRsrcAlloc   timeDomRsrcAllociList[MAX_NUM_DL_ALLOC]; /* PDSCH time domain DL resource allocation list */
691    RBGSize                 rbgSize;
692    CodeWordsSchedDci       numCodeWordsSchByDci;                    /* Number of code words scheduled by DCI */
693    BundlingType            bundlingType;
694 }PdschConfig;
695
696 /* Initial Downlink BWP */
697 typedef struct initialDlBwp
698 {
699    bool          pdcchPresent;
700    PdcchConfig   pdcchCfg;
701    bool          pdschPresent;
702    PdschConfig   pdschCfg;
703 }InitialDlBwp;
704
705 /* BWP Downlink common */
706 typedef struct bwpDlCommon
707 {
708 }BwpDlCommon;
709
710 /* Downlink BWP information */
711 typedef struct dlBwpInfo
712 {
713    uint8_t          bwpId;
714 }DlBwpInfo;
715
716 /* PDCCH Serving Cell configuration */
717 typedef struct pdschServCellCfg
718 {
719    uint8_t              *maxMimoLayers;           
720    NumHarqProcForPdsch  numHarqProcForPdsch;
721    MaxCodeBlkGrpPerTB   *maxCodeBlkGrpPerTb;
722    bool                 *codeBlkGrpFlushInd;
723    PdschXOverhead       *xOverhead;
724 }PdschServCellCfg;
725
726 /* PUCCH Configuration */
727 typedef struct pucchCfg
728 {
729   /* TODO : Not used currently */ 
730 }PucchCfg;
731
732 /* Transform precoding disabled */
733 typedef struct transPrecodDisabled
734 {
735    uint16_t   scramblingId0;
736 }TransPrecodDisabled;
737
738 /* DMRS Uplink configuration */
739 typedef struct dmrsUlCfg
740 {
741    AddPosType            addPos;               /* DMRS additional position */
742    TransPrecodDisabled   transPrecodDisabled;  /* Transform precoding disabled */
743 }DmrsUlCfg;
744
745 /* PUSCH Time Domain Resource Allocation */
746 typedef struct puschTimeDomRsrcAlloc
747 {
748    uint8_t   k2;
749    CommonMappingType   mappingType;
750    uint8_t   startSymbolAndLength;
751 }PuschTimeDomRsrcAlloc;
752
753 /* PUSCH Configuration */
754 typedef struct puschCfg
755 {
756    DmrsUlCfg               dmrsUlCfgForPuschMapTypeA;
757    ResAllocType            resourceAllocType;
758    uint8_t                 numTimeDomRsrcAlloc;
759    PuschTimeDomRsrcAlloc   timeDomRsrcAllocList[MAX_NUM_UL_ALLOC]; /* PUSCH time domain UL resource allocation list */
760    TransformPrecoder       transformPrecoder;
761 }PuschCfg;
762
763 /* Initial Uplink BWP */
764 typedef struct initialUlBwp
765 {
766    bool       pucchPresent;
767    PucchCfg   pucchCfg; 
768    bool       puschPresent;
769    PuschCfg   puschCfg;
770 }InitialUlBwp;
771
772 /* Uplink BWP information */
773 typedef struct ulBwpInfo
774 {
775    uint8_t        bwpId;
776 }UlBwpInfo;
777
778 /* Serving cell configuration */
779 typedef struct servCellCfgInfo
780 {
781    InitialDlBwp       initDlBwp;
782    uint8_t            numDlBwpToAdd;
783    DlBwpInfo          DlBwpToAddList[MAX_NUM_BWP];
784    uint8_t            firstActvDlBwpId;
785    uint8_t            defaultDlBwpId;
786    uint8_t            *bwpInactivityTmr;
787    PdschServCellCfg   pdschServCellCfg;
788    InitialUlBwp       initUlBwp;
789    uint8_t            numUlBwpToAdd;
790    UlBwpInfo          UlBwpToAddList[MAX_NUM_BWP];
791    uint8_t            firstActvUlBwpId;
792 }ServCellCfgInfo;
793
794 /* Special cell configuration */
795 typedef struct spCellCfg
796 {
797    uint8_t           servCellIdx;
798    ServCellCfgInfo   servCellCfg;
799 }SpCellCfg;
800
801 typedef struct maxAggrBitRate
802 {
803    uint32_t ulBits;
804    uint32_t dlBits;
805 }MaxAggrBitRate;
806
807 /* Single Network Slice Selection assistance Info */
808 typedef struct snssai
809 {
810    uint8_t sst;                /* Slice Type */
811    uint8_t sd[SD_SIZE];        /* Slice Differentiator */
812 }Snssai;
813
814 typedef struct nonDynFiveQi
815 {
816    uint16_t   fiveQi;
817    uint8_t    priorLevel;
818    uint16_t   avgWindow;
819    uint16_t   maxDataBurstVol;
820 }NonDynFiveQi;
821
822 typedef struct dynFiveQi
823 {
824    uint8_t    priorLevel;
825    uint16_t   packetDelayBudget;
826    uint8_t    packetErrRateScalar;
827    uint8_t    packetErrRateExp;
828    uint16_t   fiveQi;
829    uint8_t    delayCritical;
830    uint16_t   avgWindow;
831    uint16_t   maxDataBurstVol;
832 }DynFiveQi;
833
834 typedef struct ngRanAllocAndRetPri
835 {
836   uint8_t priorityLevel;
837   uint8_t preEmptionCap;
838   uint8_t preEmptionVul;
839 }NgRanAllocAndRetPri;
840
841 typedef struct grbQosInfo
842 {
843   uint32_t maxFlowBitRateDl;
844   uint32_t maxFlowBitRateUl;
845   uint32_t guarFlowBitRateDl;
846   uint32_t guarFlowBitRateUl;
847 }GrbQosInfo;
848
849 typedef struct drbQos
850 {
851    uint8_t  fiveQiType;   /* Dynamic or non-dynamic */ 
852    union
853    {
854       NonDynFiveQi   nonDyn5Qi;
855       DynFiveQi      dyn5Qi;
856    }u;
857    NgRanAllocAndRetPri ngRanRetPri;
858    GrbQosInfo grbQosInfo;
859    uint16_t             pduSessionId;
860    uint32_t             ulPduSessAggMaxBitRate;
861 }DrbQosInfo;
862
863 typedef struct ulLcCfg
864 {
865    uint8_t priority;
866    uint8_t lcGroup;
867    uint8_t schReqId;
868    uint8_t pbr;        // prioritisedBitRate
869    uint8_t bsd;        // bucketSizeDuration
870 }UlLcCfg;
871
872 typedef struct duLcCfg
873 {
874    LcPriority lcp;      // logical Channel Prioritization
875 }DlLcCfg;
876
877 typedef struct lcCfg
878 {
879    uint8_t lcId;
880    DrbQosInfo *drbQos; 
881    Snssai  *snssai;
882    UlLcCfg *ulLcCfg;
883    DlLcCfg dlLcCfg;
884
885 }LcCfg;
886
887 typedef struct macUeCfg
888 {
889    uint16_t cellIdx;
890    uint8_t  ueIdx;
891    uint16_t crnti;
892    MacCellGrpCfg macCellGrpCfg;
893    PhyCellGrpCfg phyCellGrpCfg;
894    SpCellCfg spCellCfg;
895    MaxAggrBitRate *maxAggrBitRate;
896    uint8_t numLcs;
897    LcCfg lcCfgList[MAX_NUM_LOGICAL_CHANNELS];
898 }MacUeCfg;
899
900 /* Functions for slot Ind from MAC to DU APP*/
901 typedef uint16_t (*DuMacSlotInd) ARGS((
902    Pst       *pst,
903    SlotInfo  *slotInfo ));
904
905 /* Functions for stop Ind from MAC to DU APP*/
906 typedef uint16_t (*DuMacStopInd) ARGS((
907    Pst       *pst,
908    MacCellStopInfo  *cellId ));
909
910 /* Functions for mac cell start req */
911 typedef uint16_t (*DuMacCellStartReq) ARGS((
912    Pst               *pst, 
913    MacCellStartInfo  *cellStartInfo ));
914
915 /* Functions for mac cell stop request */
916 typedef uint16_t (*DuMacCellStopReq) ARGS((
917    Pst               *pst,
918    MacCellStopInfo  *cellStopInfo ));
919  
920 /* Function pointers for packing macCellCfg Request and Confirm */
921 typedef int (*packMacCellCfgReq) ARGS((
922    Pst           *pst,
923    MacCellCfg    *macCellCfg ));
924
925 typedef int (*packMacCellCfgConfirm) ARGS((
926    Pst              *pst,
927    MacCellCfgCfm    *macCellCfgCfm ));
928
929 typedef int (*DuMacCellCfgReq) ARGS((
930    Pst        *pst,        
931    MacCellCfg *macCellCfg));
932
933 typedef int (*DuMacCellCfgCfm) ARGS((
934    Pst        *pst,        
935    MacCellCfgCfm *macCellCfgCfm ));
936
937 /* Functions for UL CCCH Ind from MAC to DU APP*/
938 typedef uint16_t (*DuMacUlCcchInd) ARGS((
939    Pst           *pst,
940    UlCcchIndInfo *ulCcchIndInfo ));
941
942 /* Functions for DL CCCH Ind from DU APP to MAC*/
943 typedef uint16_t (*DuMacDlCcchInd) ARGS((
944    Pst           *pst,
945    DlCcchIndInfo *dlCcchIndInfo ));
946
947 /* UE create Request from DU APP to MAC*/
948 typedef uint8_t (*DuMacUeCreateReq) ARGS((
949    Pst           *pst,
950    MacUeCfg      *ueCfg ));
951
952 extern uint16_t packMacSlotInd(Pst *pst, SlotInfo *slotInfo );
953 extern uint16_t unpackMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf);
954 extern uint16_t duHandleSlotInd(Pst *pst, SlotInfo *slotInfo);
955 extern uint16_t packMacCellStartReq(Pst *pst, MacCellStartInfo *cellStartInfo);
956 extern uint16_t unpackMacCellStartReq(DuMacCellStartReq func, Pst *pst, Buffer *mBuf);
957 extern uint16_t MacHdlCellStartReq(Pst *pst, MacCellStartInfo  *cellStartInfo);
958 extern uint16_t packMacCellStopReq(Pst *pst, MacCellStopInfo  *cellStopInfo);
959 extern uint16_t unpackMacCellStopReq(DuMacCellStopReq func, Pst *pst, Buffer *mBuf);
960 extern uint16_t MacHdlCellStopReq(Pst *pst, MacCellStopInfo  *cellStopInfo);
961 extern int  packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg);
962 extern int MacHdlCellCfgReq(Pst *pst, MacCellCfg *macCellCfg);
963 extern void cmUnpackLwLcMacCellCfg(DuMacCellCfgReq func, Pst *pst, Buffer *mBuf);
964 extern int unpackMacCellCfgCfm(DuMacCellCfgCfm func, Pst *pst, Buffer *mBuf);
965 extern int duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm);
966 extern uint16_t packMacStopInd(Pst *pst, MacCellStopInfo *cellId);
967 extern uint16_t unpackMacStopInd(DuMacStopInd func, Pst *pst, Buffer *mBuf);
968 extern uint16_t duHandleStopInd(Pst *pst, MacCellStopInfo *cellId);
969 extern uint16_t packMacUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo);
970 extern uint16_t unpackMacUlCcchInd(DuMacUlCcchInd func, Pst *pst, Buffer *mBuf);
971 extern uint16_t duHandleUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo);
972 extern uint16_t packMacDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo);
973 extern uint16_t unpackMacDlCcchInd(DuMacDlCcchInd func, Pst *pst, Buffer *mBuf);
974 extern uint16_t MacHdlDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo);
975 extern uint8_t packDuMacUeCreateReq(Pst *pst, MacUeCfg *ueCfg);
976 extern uint8_t unpackMacUeCreateReq(DuMacUeCreateReq func, Pst *pst, Buffer *mBuf);
977 extern uint8_t MacHdlUeCreateReq(Pst *pst, MacUeCfg *ueCfg);
978 uint8_t sendStopIndMacToDuApp();
979 #endif
980
981 /**********************************************************************
982          End of file
983 **********************************************************************/