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