JIRA ID ODUHIGH193: Allocation and deallocation of MaceCellCfg sharable buffer
[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            cellId;           /* Cell Id */
583    U8             numTlv;           /* Number of configuration TLVs */
584    U8             carrierId;        /* Carrired Index */
585    U16            phyCellId;        /* Physical cell id */
586    DuplexMode     dupType;          /* Duplex type: TDD/FDD */
587    CarrierCfg     dlCarrCfg;        /* DL Carrier configuration */
588    CarrierCfg     ulCarrCfg;        /* UL Carrier configuration */
589    Bool           freqShft;         /* Indicates presence of 7.5kHz frequency shift */
590    SsbCfg         ssbCfg;           /* SSB configuration */          
591    PrachCfg       prachCfg;         /* PRACH Configuration */
592    TDDCfg         tddCfg;           /* TDD periodicity and slot configuration */
593    RSSIMeasUnit   rssiUnit;         /* RSSI measurement unit */
594    Sib1CellCfg    sib1Cfg;          /* SIB1 config */
595    BwpDlConfig    initialDlBwp;     /* Initial DL BWP */
596    BwpUlConfig    initialUlBwp;     /* Initial UL BWP */
597    uint8_t        dmrsTypeAPos;     /* DMRS Type A position */
598 }MacCellCfg;
599
600 typedef struct macCellCfgCfm
601 {
602    U16            cellId;
603    uint8_t        rsp; 
604 }MacCellCfgCfm;
605
606 typedef struct slotInfo
607 {
608    uint16_t cellId;
609    uint16_t sfn;
610    uint16_t slot;
611 }SlotInfo;
612
613 typedef struct macCellStartInfo
614 {
615    uint16_t cellId;
616 }MacCellStartInfo;
617
618 typedef struct macCellStopInfo
619 {
620    uint16_t cellId;
621 }MacCellStopInfo;
622
623 typedef struct ulCcchInd
624 {
625    uint16_t cellId;
626    uint16_t crnti;
627    uint8_t  *ulCcchMsg;
628 }UlCcchIndInfo;
629
630 typedef struct dlCcchInd
631 {
632    uint16_t      cellId;
633    uint16_t      crnti;
634    DlCcchMsgType msgType;
635    uint16_t      dlCcchMsgLen;
636    uint8_t       *dlCcchMsg;
637 }DlCcchIndInfo;
638
639 typedef struct bsrTmrCfg
640 {
641    uint8_t periodicTimer;
642    uint8_t retxTimer;
643    uint8_t srDelayTimer;
644 }BsrTmrCfg;
645
646
647 /* Info of Scheduling Request to Add/Modify */
648 typedef struct schedReqInfo
649 {
650    uint8_t         schedReqId;
651    SrProhibitTimer srProhibitTmr;
652    SrTransMax      srTransMax;
653 }SchedReqInfo;
654
655 /* Scheduling Request Configuration */
656 typedef struct schedReqCfg
657 {
658    uint8_t       addModListCount;
659    SchedReqInfo  addModList[MAX_NUM_SR_CFG_PER_CELL_GRP];   /* List of Scheduling req to be added/modified */
660    uint8_t       relListCount;
661    uint8_t       relList[MAX_NUM_SR_CFG_PER_CELL_GRP];      /* list of scheduling request Id to be deleted */
662 }SchedReqCfg;
663
664 typedef struct tagInfo
665 {
666    uint8_t tagId;
667    TimeAlignmentTimer timeAlignTimer;
668 }TagInfo;
669
670 typedef struct tagCfg
671 {
672    uint8_t      addModListCount;
673    TagInfo      addModList[MAC_NUM_TAGS];  /* List of Tag to Add/Modify */
674    uint8_t      relListCount;
675    uint8_t      relList[MAC_NUM_TAGS];     /* list of Tag Id to release */
676 }TagCfg;
677
678 typedef struct phrCfg
679 {
680    PhrPeriodicTimer periodicTimer;
681    PhrProhibitTimer prohibitTimer; 
682    PhrTxPwrFactorChange txPowerFactor;
683    bool     multiplePHR;       
684    bool     dummy;
685    bool     phrType2OtherCell;
686    PhrModeOtherCG phrOtherCG;
687 }PhrCfg;
688
689 typedef struct macCellGrpCfg
690 {
691    SchedReqCfg schReqCfg;
692    TagCfg      tagCfg;
693    BsrTmrCfg   bsrTmrCfg;
694    bool        phrCfgSetupPres;   /* true/false: phrCfgSetup/phrCfgRelease */
695    PhrCfg      phrCfg;
696 }MacCellGrpCfg;
697
698 typedef struct phyCellGrpCfg
699 {
700    PdschHarqAckCodebook  pdschHarqAckCodebook;
701    uint8_t    pNrFr1;
702 }PhyCellGrpCfg;
703
704 /* Control resource set info */
705 typedef struct controlRsrcSet
706 {
707    uint8_t     cRSetId;                /* Control resource set id */
708    uint8_t     freqDomainRsrc[FREQ_DOM_RSRC_SIZE];  /* Frequency domain resource */
709    uint8_t     duration;
710    REGMappingType cceRegMappingType;
711    PrecoderGranul precoderGranularity;
712    uint16_t    dmrsScramblingId;
713 }ControlRsrcSet;
714
715 /* Search Space info */
716 typedef struct searchSpace
717 {
718    uint8_t     searchSpaceId;
719    uint8_t     cRSetId;
720    MSlotPeriodAndOffset  mSlotPeriodicityAndOffset;
721    uint8_t     mSymbolsWithinSlot[MONITORING_SYMB_WITHIN_SLOT_SIZE];
722    AggrLevel   numCandidatesAggLevel1;      /* Number of candidates for aggregation level 1 */
723    AggrLevel   numCandidatesAggLevel2;      /* Number of candidates for aggregation level 2 */
724    AggrLevel   numCandidatesAggLevel4;      /* Number of candidates for aggregation level 4 */
725    AggrLevel   numCandidatesAggLevel8;      /* Number of candidates for aggregation level 8 */
726    AggrLevel   numCandidatesAggLevel16;     /* Number of candidates for aggregation level 16 */
727    SearchSpaceType searchSpaceType;
728    uint8_t     ueSpecificDciFormat;
729 }SearchSpace;
730
731 /* PDCCH cofniguration */
732 typedef struct pdcchConfig
733 {
734    uint8_t           numCRsetToAddMod;
735    ControlRsrcSet    cRSetToAddModList[MAX_NUM_CRSET];           /* List of control resource set to add/modify */
736    uint8_t           numCRsetToRel;
737    uint8_t           cRSetToRelList[MAX_NUM_CRSET];              /* List of control resource set to release */
738    uint8_t           numSearchSpcToAddMod;
739    SearchSpace       searchSpcToAddModList[MAX_NUM_SEARCH_SPC];  /* List of search space to add/modify */
740    uint8_t           numSearchSpcToRel;
741    uint8_t           searchSpcToRelList[MAX_NUM_SEARCH_SPC];     /* List of search space to release */
742 }PdcchConfig;
743
744 /* PDSCH time domain resource allocation */
745 typedef struct pdschTimeDomRsrcAlloc
746 {
747    CommonMappingType mappingType;
748    uint8_t           startSymbol;
749    uint8_t           symbolLength;
750    uint8_t           startSymbolAndLength;
751 }PdschTimeDomRsrcAlloc;
752
753 /* DMRS downlink configuration */
754 typedef struct dmrsDlCfg
755 {
756    AddPosType  addPos;       /* DMRS additional position */
757 }DmrsDlCfg;
758
759 /* PDSCH Configuration */
760 typedef struct pdschConfig
761 {
762    DmrsDlCfg               dmrsDlCfgForPdschMapTypeA;
763    ResAllocType            resourceAllocType;
764    uint8_t                 numTimeDomRsrcAlloc;
765    PdschTimeDomRsrcAlloc   timeDomRsrcAllociList[MAX_NUM_DL_ALLOC]; /* PDSCH time domain DL resource allocation list */
766    RBGSize                 rbgSize;
767    CodeWordsSchedDci       numCodeWordsSchByDci;                    /* Number of code words scheduled by DCI */
768    BundlingType            bundlingType;
769 }PdschConfig;
770
771 /* Initial Downlink BWP */
772 typedef struct initialDlBwp
773 {
774    bool          pdcchPresent;
775    PdcchConfig   pdcchCfg;
776    bool          pdschPresent;
777    PdschConfig   pdschCfg;
778 }InitialDlBwp;
779
780 /* BWP Downlink common */
781 typedef struct bwpDlCommon
782 {
783 }BwpDlCommon;
784
785 /* Downlink BWP information */
786 typedef struct dlBwpInfo
787 {
788    uint8_t          bwpId;
789 }DlBwpInfo;
790
791 /* PDCCH Serving Cell configuration */
792 typedef struct pdschServCellCfg
793 {
794    uint8_t              *maxMimoLayers;           
795    NumHarqProcForPdsch  numHarqProcForPdsch;
796    MaxCodeBlkGrpPerTB   *maxCodeBlkGrpPerTb;
797    bool                 *codeBlkGrpFlushInd;
798    PdschXOverhead       *xOverhead;
799 }PdschServCellCfg;
800
801 /* PUCCH Configuration */
802 typedef struct pucchCfg
803 {
804    /* TODO : Not used currently */ 
805 }PucchCfg;
806
807 /* Transform precoding disabled */
808 typedef struct transPrecodDisabled
809 {
810    uint16_t   scramblingId0;
811 }TransPrecodDisabled;
812
813 /* DMRS Uplink configuration */
814 typedef struct dmrsUlCfg
815 {
816    AddPosType            addPos;               /* DMRS additional position */
817    TransPrecodDisabled   transPrecodDisabled;  /* Transform precoding disabled */
818 }DmrsUlCfg;
819
820 /* PUSCH Time Domain Resource Allocation */
821 typedef struct puschTimeDomRsrcAlloc
822 {
823    uint8_t   k2;
824    CommonMappingType   mappingType;
825    uint8_t           startSymbol;
826    uint8_t           symbolLength;
827    uint8_t   startSymbolAndLength;
828 }PuschTimeDomRsrcAlloc;
829
830 /* PUSCH Configuration */
831 typedef struct puschCfg
832 {
833    DmrsUlCfg               dmrsUlCfgForPuschMapTypeA;
834    ResAllocType            resourceAllocType;
835    uint8_t                 numTimeDomRsrcAlloc;
836    PuschTimeDomRsrcAlloc   timeDomRsrcAllocList[MAX_NUM_UL_ALLOC]; /* PUSCH time domain UL resource allocation list */
837    TransformPrecoder       transformPrecoder;
838 }PuschCfg;
839
840 /* Initial Uplink BWP */
841 typedef struct initialUlBwp
842 {
843    bool       pucchPresent;
844    PucchCfg   pucchCfg; 
845    bool       puschPresent;
846    PuschCfg   puschCfg;
847 }InitialUlBwp;
848
849 /* Uplink BWP information */
850 typedef struct ulBwpInfo
851 {
852    uint8_t        bwpId;
853 }UlBwpInfo;
854
855 /* Serving cell configuration */
856 typedef struct servCellCfgInfo
857 {
858    InitialDlBwp       initDlBwp;
859    uint8_t            numDlBwpToAdd;
860    DlBwpInfo          DlBwpToAddList[MAX_NUM_BWP];
861    uint8_t            firstActvDlBwpId;
862    uint8_t            defaultDlBwpId;
863    uint8_t            *bwpInactivityTmr;
864    PdschServCellCfg   pdschServCellCfg;
865    InitialUlBwp       initUlBwp;
866    uint8_t            numUlBwpToAdd;
867    UlBwpInfo          UlBwpToAddList[MAX_NUM_BWP];
868    uint8_t            firstActvUlBwpId;
869 }ServCellCfgInfo;
870
871 /* Special cell configuration */
872 typedef struct spCellCfg
873 {
874    uint8_t           servCellIdx;
875    ServCellCfgInfo   servCellCfg;
876 }SpCellCfg;
877
878 typedef struct maxAggrBitRate
879 {
880    uint32_t ulBits;
881    uint32_t dlBits;
882 }MaxAggrBitRate;
883
884 /* Single Network Slice Selection assistance Info */
885 typedef struct snssai
886 {
887    uint8_t sst;                /* Slice Type */
888    uint8_t sd[SD_SIZE];        /* Slice Differentiator */
889 }Snssai;
890
891 typedef struct nonDynFiveQi
892 {
893    uint16_t   fiveQi;
894    uint8_t    priorLevel;
895    uint16_t   avgWindow;
896    uint16_t   maxDataBurstVol;
897 }NonDynFiveQi;
898
899 typedef struct dynFiveQi
900 {
901    uint8_t    priorLevel;
902    uint16_t   packetDelayBudget;
903    uint8_t    packetErrRateScalar;
904    uint8_t    packetErrRateExp;
905    uint16_t   fiveQi;
906    uint8_t    delayCritical;
907    uint16_t   avgWindow;
908    uint16_t   maxDataBurstVol;
909 }DynFiveQi;
910
911 typedef struct ngRanAllocAndRetPri
912 {
913    uint8_t priorityLevel;
914    uint8_t preEmptionCap;
915    uint8_t preEmptionVul;
916 }NgRanAllocAndRetPri;
917
918 typedef struct grbQosInfo
919 {
920    uint32_t maxFlowBitRateDl;
921    uint32_t maxFlowBitRateUl;
922    uint32_t guarFlowBitRateDl;
923    uint32_t guarFlowBitRateUl;
924 }GrbQosInfo;
925
926 typedef struct drbQos
927 {
928    uint8_t  fiveQiType;   /* Dynamic or non-dynamic */ 
929    union
930    {
931       NonDynFiveQi   nonDyn5Qi;
932       DynFiveQi      dyn5Qi;
933    }u;
934    NgRanAllocAndRetPri ngRanRetPri;
935    GrbQosInfo grbQosInfo;
936    uint16_t             pduSessionId;
937    uint32_t             ulPduSessAggMaxBitRate;
938 }DrbQosInfo;
939
940 typedef struct ulLcCfg
941 {
942    uint8_t priority;
943    uint8_t lcGroup;
944    uint8_t schReqId;
945    uint8_t pbr;        // prioritisedBitRate
946    uint8_t bsd;        // bucketSizeDuration
947 }UlLcCfg;
948
949 typedef struct duLcCfg
950 {
951    LcPriority lcp;      // logical Channel Prioritization
952 }DlLcCfg;
953
954 typedef struct lcCfg
955 {
956    uint8_t lcId;
957    DrbQosInfo *drbQos; 
958    Snssai  *snssai;
959    UlLcCfg *ulLcCfg;
960    DlLcCfg dlLcCfg;
961
962 }LcCfg;
963
964 typedef struct macUeCfg
965 {
966    uint16_t cellId;
967    uint8_t  ueIdx;
968    uint16_t crnti;
969    MacCellGrpCfg macCellGrpCfg;
970    PhyCellGrpCfg phyCellGrpCfg;
971    SpCellCfg spCellCfg;
972    MaxAggrBitRate *maxAggrBitRate;
973    uint8_t numLcs;
974    LcCfg lcCfgList[MAX_NUM_LOGICAL_CHANNELS];
975 }MacUeCfg;
976
977 typedef struct plmnId
978 {
979    uint8_t mcc[3];
980    uint8_t mnc[3];
981 }PlmnIdentity;
982
983 typedef struct nrcgi
984 {
985    PlmnIdentity  plmn;
986    uint16_t  cellId;
987 }Nrcgi;
988
989 typedef struct srbFailInfo
990 {
991    uint8_t       srbId;
992    FailureCause  cause;
993 }SRBFailInfo;
994
995 typedef struct drbFailInfo
996 {
997    uint8_t       drbId;
998    FailureCause  cause;
999 }DRBFailInfo;
1000
1001 typedef struct sCellFailInfo
1002 {
1003    Nrcgi         nrcgi;
1004    FailureCause  cause;
1005 }SCellFailInfo;
1006
1007 typedef struct ueCfgRsp
1008 {
1009    uint16_t       cellId;
1010    uint16_t       ueIdx;
1011    MacRsp         result;
1012    uint8_t        numSRBFailed;   /* valid values : 0 to MAX_NUM_SRB */ 
1013    SRBFailInfo    *failedSRBlisti;
1014    uint8_t        numDRBFailed;   /* valid values : 0 to MAX_NUM_DRB */
1015    DRBFailInfo    *failedDRBlist;
1016    uint8_t        numSCellFailed; /* valid values : 0 to MAX_NUM_SCELL */
1017    SCellFailInfo  *failedSCellList;
1018 }MacUeCfgRsp;
1019
1020 /* Functions for slot Ind from MAC to DU APP*/
1021 typedef uint16_t (*DuMacSlotInd) ARGS((
1022    Pst       *pst,
1023    SlotInfo  *slotInfo ));
1024
1025 /* Functions for stop Ind from MAC to DU APP*/
1026 typedef uint16_t (*DuMacStopInd) ARGS((
1027    Pst       *pst,
1028    MacCellStopInfo  *cellId ));
1029
1030 /* Functions for mac cell start req */
1031 typedef uint16_t (*DuMacCellStartReq) ARGS((
1032    Pst               *pst, 
1033    MacCellStartInfo  *cellStartInfo ));
1034
1035 /* Functions for mac cell stop request */
1036 typedef uint16_t (*DuMacCellStopReq) ARGS((
1037    Pst               *pst,
1038    MacCellStopInfo  *cellStopInfo ));
1039
1040 /* Function pointers for packing macCellCfg Request and Confirm */
1041 typedef int (*packMacCellCfgReq) ARGS((
1042    Pst           *pst,
1043    MacCellCfg    *macCellCfg ));
1044
1045 typedef int (*packMacCellCfgConfirm) ARGS((
1046    Pst              *pst,
1047    MacCellCfgCfm    *macCellCfgCfm ));
1048
1049 typedef int (*DuMacCellCfgReq) ARGS((
1050    Pst        *pst,        
1051    MacCellCfg *macCellCfg));
1052
1053 typedef int (*DuMacCellCfgCfm) ARGS((
1054    Pst        *pst,        
1055    MacCellCfgCfm *macCellCfgCfm ));
1056
1057 /* Functions for UL CCCH Ind from MAC to DU APP*/
1058 typedef uint16_t (*DuMacUlCcchInd) ARGS((
1059    Pst           *pst,
1060    UlCcchIndInfo *ulCcchIndInfo ));
1061
1062 /* Functions for DL CCCH Ind from DU APP to MAC*/
1063 typedef uint16_t (*DuMacDlCcchInd) ARGS((
1064    Pst           *pst,
1065    DlCcchIndInfo *dlCcchIndInfo ));
1066
1067 /* UE create Request from DU APP to MAC*/
1068 typedef uint8_t (*DuMacUeCreateReq) ARGS((
1069    Pst           *pst,
1070    MacUeCfg      *ueCfg ));
1071
1072 /* UE create Response from MAC to DU APP */
1073 typedef uint8_t (*DuMacUeCreateRspFunc) ARGS((
1074    Pst           *pst, 
1075    MacUeCfgRsp   *cfgRsp));
1076
1077 extern uint16_t packMacSlotInd(Pst *pst, SlotInfo *slotInfo );
1078 extern uint16_t unpackMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf);
1079 extern uint16_t duHandleSlotInd(Pst *pst, SlotInfo *slotInfo);
1080 extern uint16_t packMacCellStartReq(Pst *pst, MacCellStartInfo *cellStartInfo);
1081 extern uint16_t unpackMacCellStartReq(DuMacCellStartReq func, Pst *pst, Buffer *mBuf);
1082 extern uint16_t MacHdlCellStartReq(Pst *pst, MacCellStartInfo  *cellStartInfo);
1083 extern uint16_t packMacCellStopReq(Pst *pst, MacCellStopInfo  *cellStopInfo);
1084 extern uint16_t unpackMacCellStopReq(DuMacCellStopReq func, Pst *pst, Buffer *mBuf);
1085 extern uint16_t MacHdlCellStopReq(Pst *pst, MacCellStopInfo  *cellStopInfo);
1086 extern int  packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg);
1087 extern int MacHdlCellCfgReq(Pst *pst, MacCellCfg *macCellCfg);
1088 extern void cmUnpackLwLcMacCellCfg(DuMacCellCfgReq func, Pst *pst, Buffer *mBuf);
1089 extern int unpackMacCellCfgCfm(DuMacCellCfgCfm func, Pst *pst, Buffer *mBuf);
1090 extern int duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm);
1091 extern uint16_t packMacStopInd(Pst *pst, MacCellStopInfo *cellId);
1092 extern uint16_t unpackMacStopInd(DuMacStopInd func, Pst *pst, Buffer *mBuf);
1093 extern uint16_t duHandleStopInd(Pst *pst, MacCellStopInfo *cellId);
1094 extern uint16_t packMacUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo);
1095 extern uint16_t unpackMacUlCcchInd(DuMacUlCcchInd func, Pst *pst, Buffer *mBuf);
1096 extern uint16_t duHandleUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo);
1097 extern uint16_t packMacDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo);
1098 extern uint16_t unpackMacDlCcchInd(DuMacDlCcchInd func, Pst *pst, Buffer *mBuf);
1099 extern uint16_t MacHdlDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo);
1100 extern uint8_t packDuMacUeCreateReq(Pst *pst, MacUeCfg *ueCfg);
1101 extern uint8_t unpackMacUeCreateReq(DuMacUeCreateReq func, Pst *pst, Buffer *mBuf);
1102 extern uint8_t MacHdlUeCreateReq(Pst *pst, MacUeCfg *ueCfg);
1103 uint8_t sendStopIndMacToDuApp();
1104 extern uint8_t packDuMacUeCreateRsp(Pst *pst, MacUeCfgRsp *cfgRsp);
1105 extern uint8_t unpackDuMacUeCreateRsp(DuMacUeCreateRspFunc func, Pst *pst, Buffer *mBuf);
1106 extern uint8_t duHandleMacUeCreateRsp(Pst *pst, MacUeCfgRsp *cfgRsp);
1107 #endif
1108
1109 /**********************************************************************
1110   End of file
1111  **********************************************************************/