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