PUSCH PDU for msg3 and UL-CCCH Ind flow completion
[o-du/l2.git] / src / cm / mac_sch_interface.h
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18
19 /* events */
20 #define EVENT_SCH_CELL_CFG      1
21 #define EVENT_SCH_CELL_CFG_CFM  2
22 #define EVENT_DL_ALLOC          3 
23 #define EVENT_UL_SCH_INFO       4 
24 #define EVENT_RACH_IND_TO_SCH        5
25 #define EVENT_CRC_IND_TO_SCH         6
26 #define EVENT_DL_RLC_BO_INFO_TO_SCH  7
27
28 /* selector */
29 #define MAC_SCH_LC_SELECTOR 0
30 #define MAC_SCH_TC_SELECTOR 1
31 #define MAC_SCH_LWLC_SELECTOR 2
32
33 /*macros*/
34 #define NO_SSB 0
35 #define SSB_TRANSMISSION 1
36 #define SSB_REPEAT 2
37 #define MAX_SSB_IDX 1 /* forcing it as 1 for now. Right value is 64 */
38
39 #define NO_SIB1 0
40 #define SIB1_TRANSMISSION 1
41 #define SIB1_REPITITION 2
42
43 #define MAX_NUM_PRG     1 /* max value should be later 275 */
44 #define MAX_DIG_BF_INTERFACES 0 /* max value should be later 255 */
45 #define MAX_CODEWORDS  1  /* max should be 2 */
46 #define SCH_HARQ_PROC_ID 1 /* harq proc id */
47 #define SCH_ALLOC_TYPE_1 1 /*sch res alloc type */
48
49 /* Datatype in UL SCH Info */
50 #define SCH_DATATYPE_PUSCH 1
51 #define SCH_DATATYPE_PUSCH_UCI 2
52 #define SCH_DATATYPE_UCI 4
53 #define SCH_DATATYPE_SRS 8
54 #define SCH_DATATYPE_PRACH 16
55
56 #define MAX_NUMBER_OF_CRC_IND_BITS 1
57 #define MAX_NUM_LOGICAL_CHANNELS   11
58
59 #define CCCH_LCID  0
60
61 /*structures*/
62
63
64 typedef enum
65 {
66         RSP_OK,
67         RSP_NOK
68 }schMacRsp;
69
70 typedef struct
71 {
72    uint32_t    ssbPbchPwr;       /* SSB block power */
73    uint8_t     scsCommon;           /* subcarrier spacing for common [0-3]*/
74    uint8_t     ssbOffsetPointA;  /* SSB sub carrier offset from point A */
75    SSBPeriod   ssbPeriod;        /* SSB Periodicity in msec */
76    uint8_t     ssbSubcOffset;    /* Subcarrier Offset(Kssb) */
77    uint32_t    nSSBMask[SSB_MASK_SIZE];      /* Bitmap for actually transmitted SSB. */
78 }SchSsbCfg;
79
80 typedef struct bwpCfg
81 {
82    uint8_t subcarrierSpacing;
83    uint8_t cyclicPrefix;
84    uint16_t BWPSize;
85    uint16_t BWPStart;
86 }BwpCfg;
87
88 typedef struct prg
89 {
90    uint16_t pmIdx;
91    uint16_t beamIdx[MAX_DIG_BF_INTERFACES];
92 } Prg;
93
94 typedef struct beamformingInfo
95 {
96    uint16_t numPrgs;
97    uint16_t prgSize;
98    uint8_t  digBfInterfaces;
99    Prg  prg[MAX_NUM_PRG];
100 } BeamformingInfo;
101
102 /* SIB1 PDSCH structures */
103
104 typedef struct codewordinfo
105 {
106    uint16_t targetCodeRate;
107    uint8_t  qamModOrder;
108    uint8_t  mcsIndex;
109    uint8_t  mcsTable;
110    uint8_t  rvIndex;
111    uint32_t tbSize;
112 } CodewordInfo;
113
114 typedef struct dmrsInfo
115 {
116    uint16_t dlDmrsSymbPos;
117    uint8_t  dmrsConfigType;
118    uint16_t dlDmrsScramblingId;
119    uint8_t  scid;
120    uint8_t  numDmrsCdmGrpsNoData;
121    uint16_t dmrsPorts;
122 } DmrsInfo;
123
124 typedef struct pdschFreqAlloc
125 {
126    uint8_t  resourceAlloc;
127    /* since we are using type-1, hence rbBitmap excluded */
128    uint16_t rbStart;
129    uint16_t rbSize;
130    uint8_t  vrbPrbMapping;
131 } PdschFreqAlloc;
132
133 typedef struct pdschTimeAlloc
134 {
135    uint8_t rowIndex;
136    uint8_t startSymbolIndex;
137    uint8_t numSymbols;
138 } PdschTimeAlloc;
139
140 typedef struct txPowerPdschInfo
141 {
142    uint8_t powerControlOffset;
143    uint8_t powerControlOffsetSS;
144 } TxPowerPdschInfo;
145
146 typedef struct pdschCfg
147 {
148    uint16_t pduBitmap;
149    uint16_t rnti;
150    uint16_t pduIndex;
151    BwpCfg pdschBwpCfg;
152    uint8_t numCodewords;
153    CodewordInfo codeword[MAX_CODEWORDS];
154    uint16_t dataScramblingId;
155    uint8_t  numLayers;
156    uint8_t  transmissionScheme;
157    uint8_t  refPoint;
158    DmrsInfo dmrs;
159    PdschFreqAlloc freqAlloc;
160    PdschTimeAlloc timeAlloc;
161    BeamformingInfo beamPdschInfo;
162    TxPowerPdschInfo txPdschPower;
163 } PdschCfg;
164 /* SIB1 PDSCH structures end */
165
166 /* SIB1 interface structure */
167
168 typedef struct coresetCfg
169 {
170    uint8_t coreSet0Size;
171    uint8_t startSymbolIndex;
172    uint8_t durationSymbols;
173    uint8_t freqDomainResource[6];
174    uint8_t cceRegMappingType;
175    uint8_t regBundleSize;
176    uint8_t interleaverSize;
177    uint8_t coreSetType;
178    uint16_t shiftIndex;
179    uint8_t precoderGranularity;
180    uint8_t cceIndex;
181    uint8_t aggregationLevel;
182 } CoresetCfg;
183
184 typedef struct txPowerPdcchInfo
185 {
186    uint8_t powerValue;
187    uint8_t powerControlOffsetSS;
188 } TxPowerPdcchInfo;
189
190 typedef struct dlDCI
191 {
192    uint16_t rnti;
193    uint16_t scramblingId;
194    uint16_t scramblingRnti;
195    uint8_t cceIndex;
196    uint8_t aggregLevel;
197    BeamformingInfo beamPdcchInfo;
198    TxPowerPdcchInfo txPdcchPower;
199    PdschCfg     *pdschCfg;
200 } DlDCI;
201
202 typedef struct pdcchCfg
203 {
204    BwpCfg pdcchBwpCfg;
205    /* coreset-0 configuration */
206    CoresetCfg coreset0Cfg;
207
208    uint16_t numDlDci;
209    DlDCI    dci; /* as of now its only one DCI, later it will be numDlCi */
210 } PdcchCfg;
211 /* end of SIB1 PDCCH structures */
212
213 typedef struct
214 {
215    /* parameters recieved from DU-APP */
216    uint16_t sib1PduLen;
217    uint16_t sib1NewTxPeriod;
218    uint16_t sib1RepetitionPeriod;
219    uint8_t  coresetZeroIndex;     /* derived from 4 LSB of pdcchSib1 present in MIB */
220    uint8_t  searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */
221    uint16_t sib1Mcs;
222         
223         /* parameters derived in scheduler */
224         uint8_t n0;
225    PdcchCfg sib1PdcchCfg;
226    PdschCfg sib1PdschCfg;
227 }SchSib1Cfg;
228
229 typedef struct schRachCfg
230 {
231    uint8_t      prachCfgIdx; /* PRACH config idx */
232    uint8_t      prachSubcSpacing; /* Subcarrier spacing of RACH */
233         uint16_t     msg1FreqStart;     /* Msg1-FrequencyStart */
234         uint8_t      msg1Fdm;             /* PRACH FDM (1,2,4,8) */
235    uint16_t     rootSeqIdx;        /* Root sequence index */
236    uint8_t      numRootSeq;        /* Number of root sequences required for FD */
237    uint16_t     k1;                /* Frequency Offset for each FD */
238    uint8_t      ssbPerRach;          /* SSB per RACH occassion */
239    uint8_t      prachMultCarrBand;    /* Presence of Multiple carriers in Band */
240         uint8_t      raContResTmr;        /* RA Contention Resoultion Timer */
241         uint8_t      rsrpThreshSsb;       /* RSRP Threshold SSB */
242    uint8_t      raRspWindow;         /* RA Response Window */
243 }SchRachCfg;
244
245 typedef struct schBwpParams
246 {
247    uint16_t firstPrb;
248    uint16_t numPrb;
249         uint8_t  scs;
250         uint8_t  cyclicPrefix;
251 }SchBwpParams;
252
253 typedef struct schCandidatesInfo
254 {
255    uint8_t aggLevel1;
256    uint8_t aggLevel2;
257    uint8_t aggLevel4;
258    uint8_t aggLevel8;
259    uint8_t aggLevel16;
260 }SchCandidatesInfo;
261
262 typedef struct schSearchSpaceCfg
263 {
264    uint8_t searchSpaceId;
265         uint8_t coresetId;
266         uint16_t monitoringSlot;
267         uint16_t duration;
268         uint16_t monitoringSymbol;
269         SchCandidatesInfo candidate;
270 }SchSearchSpaceCfg;
271
272 typedef struct schPdcchCfgCmn
273 {
274    SchSearchSpaceCfg raSearchSpace;
275 }SchPdcchCfgCmn;
276
277 typedef struct schPdschCfgCmn
278 {
279    uint8_t k0;
280    uint8_t mappingType;
281    uint8_t startSymbol;
282    uint8_t lengthSymbol;
283 }SchPdschCfgCmn;
284
285 typedef struct schPuschCfgCmn
286 {
287    uint8_t k2;
288    uint8_t mappingType;
289    uint8_t startSymbol;
290    uint8_t lengthSymbol;
291 }SchPuschCfgCmn;
292
293 typedef struct schBwpDlCfg
294 {
295    SchBwpParams   bwp;
296         SchPdcchCfgCmn pdcchCommon;
297         SchPdschCfgCmn pdschCommon;
298 }SchBwpDlCfg;
299
300 typedef struct schBwpUlCfg
301 {
302    SchBwpParams   bwp;
303         SchPuschCfgCmn puschCommon;
304 }SchBwpUlCfg;
305
306 typedef struct schCellCfg
307 {
308    uint16_t    cellId;     /* Cell Id */
309    uint16_t    phyCellId;  /* Physical cell id */
310         uint8_t     bandwidth;  /* Supported B/W */
311    DuplexMode  dupMode;    /* Duplex type: TDD/FDD */
312         SchSsbCfg   ssbSchCfg;  /* SSB config */
313         SchSib1Cfg  sib1SchCfg; /* SIB1 config */
314    SchRachCfg  schRachCfg; /* PRACH config */
315         SchBwpDlCfg schInitialDlBwp; /* Initial DL BWP */
316         SchBwpUlCfg schInitialUlBwp; /* Initial UL BWP */
317         uint8_t     puschMu;         /* PUSCH MU */
318 }SchCellCfg;
319
320 typedef struct schCellCfgCfm
321 {
322    U16         cellId;     /* Cell Id */
323    schMacRsp   rsp;   
324 }SchCellCfgCfm;
325
326 typedef struct timeDomainAlloc
327 {
328    uint16_t startSymb;
329         uint16_t numSymb;
330 }TimeDomainAlloc;
331
332 typedef struct freqDomainAlloc
333 {
334    uint16_t startPrb;
335    uint16_t numPrb;
336 }FreqDomainAlloc;
337
338 typedef struct ssbInfo
339 {
340    uint8_t ssbIdx;          /* SSB Index */
341         TimeDomainAlloc tdAlloc; /* Time domain allocation */
342         FreqDomainAlloc fdAlloc; /* Freq domain allocation */
343 }SsbInfo;
344
345 typedef struct sib1AllocInfo
346 {
347    PdcchCfg sib1PdcchCfg;
348    PdschCfg sib1PdschCfg;
349 } Sib1AllocInfo;
350
351 typedef struct prachSchInfo
352 {
353         uint8_t  numPrachOcas;   /* Num Prach Ocassions */
354    uint8_t  prachFormat;    /* PRACH Format */
355    uint8_t  numRa;          /* Freq domain ocassion */
356    uint8_t  prachStartSymb; /* Freq domain ocassion */
357 }PrachSchInfo;
358
359 /* Interface structure signifying DL broadcast allocation for SSB, SIB1 */
360 typedef struct dlBrdcstAlloc
361 {
362         /* Ssb transmission is determined as follows:
363          * 0 : No tranamission
364          * 1 : SSB Transmission
365          * 2 : SSB Repetition */
366         uint8_t ssbTrans;
367         uint8_t ssbIdxSupported;
368         SsbInfo ssbInfo[MAX_SSB_IDX];
369         /* Sib1 transmission is determined as follows:
370          * 0 : No tranamission
371          * 1 : SIB1 Transmission
372          * 2 : SIB1 Repetition */
373         U8 sib1Trans;
374         Sib1AllocInfo sib1Alloc;
375 }DlBrdcstAlloc;
376
377 typedef struct rarInfo
378 {
379    uint16_t raRnti;
380         uint8_t  RAPID;
381         uint16_t ta;
382         uint16_t msg3StartRb;
383         uint8_t  msg3NumRb;
384         uint16_t tcrnti;
385         uint8_t  rarPdu[8];
386         uint8_t  rarPduLen;
387 }RarInfo;
388
389 typedef struct rarAlloc
390 {
391    RarInfo rarInfo;
392    PdcchCfg rarPdcchCfg;
393    PdschCfg rarPdschCfg;
394 }RarAlloc;
395
396 typedef struct msg4Info
397 {
398         uint8_t  ndi;
399         uint8_t  harqProcNum;
400         uint8_t  dlAssignIdx;
401         uint8_t  pucchTpc;
402         uint8_t  pucchResInd;
403         uint8_t  harqFeedbackInd;
404         uint8_t  dciFormatId;
405    uint16_t crnti;
406    uint8_t  *msg4Pdu;
407    uint8_t  msg4PduLen;
408 }Msg4Info;
409
410 typedef struct msg4Alloc
411 {
412    Msg4Info msg4Info;
413    PdcchCfg msg4PdcchCfg;
414    PdschCfg msg4PdschCfg;
415 }Msg4Alloc;
416
417 typedef struct dlAlloc
418 {
419    uint16_t cellId;  /* Cell Id */
420         SlotIndInfo slotIndInfo; /* Slot Info: sfn, slot number */
421
422         /* Allocation for broadcast messages */
423    uint8_t isBroadcastPres;
424         DlBrdcstAlloc brdcstAlloc;
425
426         /* Allocation for RAR message */
427         uint8_t isRarPres;
428         RarAlloc rarAlloc;
429
430    /* Allocation from MSG4 */
431    Msg4Alloc *msg4Alloc;
432 }DlAlloc;
433
434 typedef struct tbInfo
435 {
436    uint8_t  mcs;    /* MCS */
437    uint8_t  ndi;    /* NDI */
438    uint8_t  rv;     /* Redundancy Version */
439    uint16_t tbSize; /* TB Size */
440 }TbInfo;
441
442 typedef struct schPuschInfo
443 {
444    uint8_t          harqProcId;   /* HARQ Process ID */
445    uint8_t          resAllocType; /* Resource allocation type */
446    FreqDomainAlloc  fdAlloc;      /* Freq domain allocation */
447    TimeDomainAlloc  tdAlloc;      /* Time domain allocation */
448    TbInfo           tbInfo;       /* TB info */
449 }SchPuschInfo;
450
451
452 typedef struct ulSchInfo
453 {
454    uint16_t      cellId;         /* Cell Id */
455         uint16_t      crnti;          /* CRNI */
456         SlotIndInfo   slotIndInfo;    /* Slot Info: sfn, slot number */
457         uint8_t       dataType;       /* Type of info being scheduled */
458         PrachSchInfo  prachSchInfo;   /* Prach scheduling info */
459         SchPuschInfo  schPuschInfo;   /* Pusch scheduling info */
460 }UlSchInfo;
461
462 typedef struct rachIndInfo
463 {
464    uint16_t    cellId;
465    uint16_t    crnti;
466    SlotIndInfo timingInfo;
467    uint8_t     slotIdx;
468    uint8_t     symbolIdx;
469    uint8_t     freqIdx;
470    uint8_t     preambleIdx;
471    uint16_t    timingAdv;
472 }RachIndInfo;
473
474
475 typedef struct crcIndInfo
476 {
477    uint16_t    cellId;
478    uint16_t    crnti;
479    SlotIndInfo timingInfo;
480    uint16_t    numCrcInd;
481    uint8_t     crcInd[MAX_NUMBER_OF_CRC_IND_BITS];
482 }CrcIndInfo;
483
484 typedef struct boInfo
485 {
486    uint8_t   lcId;
487    uint32_t  dataVolume;
488 }BOInfo;
489
490 typedef struct dlRlcBOInfo
491 {
492    uint16_t    cellId;
493    uint16_t    crnti;
494    uint16_t    numLc;
495    BOInfo      boInfo[MAX_NUM_LOGICAL_CHANNELS];
496 }DlRlcBOInfo;
497
498
499 /* function pointers */
500
501 typedef int (*SchCellCfgCfmFunc)    ARGS((
502    Pst            *pst,           /* Post Structure */                         
503    SchCellCfgCfm  *schCellCfgCfm  /* Cell Cfg Cfm */
504 ));
505
506 typedef int (*SchCellCfgFunc)    ARGS((
507    Pst            *pst,           /* Post Structure */                         
508    SchCellCfg  *schCellCfg     /* Cell Cfg  */
509 ));
510
511 typedef int (*SchMacDlAllocFunc)     ARGS((                     
512    Pst            *pst,       /* Post Structure */                         
513    DlAlloc        *dlAlloc    /* dl allocation Info */                      
514 ));
515
516 typedef int (*SchMacUlSchInfoFunc)     ARGS((                     
517    Pst            *pst,           /* Post Structure */                         
518    UlSchInfo      *ulSchInfo    /* UL Sch  Info */                      
519 ));
520
521 /* function declarations */
522 int packMacSchSlotInd(Pst *pst, SlotIndInfo *slotInd);
523 int packSchMacDlAlloc(Pst *pst, DlAlloc  *dlAlloc);
524 int packSchMacUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo);
525 EXTERN int packSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
526 EXTERN int packSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
527
528 EXTERN int MacProcDlAlloc(Pst *pst, DlAlloc *dlAlloc);
529 EXTERN int MacProcSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
530 EXTERN int MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
531 EXTERN int SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg);
532 EXTERN int schActvInit(Ent entity, Inst instId, Region region, Reason reason);
533 EXTERN S16 SchSendCfgCfm(Pst *pst, RgMngmt *cfm);
534 EXTERN int MacProcUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo);
535 typedef int (*MacSchRachIndFunc)(Pst *pst, RachIndInfo *rachInd);
536 int packMacSchRachInd(Pst *pst, RachIndInfo *rachInd);
537 int macSchRachInd(Pst *pst, RachIndInfo *rachInd);
538 typedef int (*MacSchCrcIndFunc)(Pst *pst, CrcIndInfo *crcInd);
539 int packMacSchCrcInd(Pst *pst, CrcIndInfo *crcInd);
540 int macSchCrcInd(Pst *pst, CrcIndInfo *crcInd);
541 typedef uint8_t (*MacSchDlRlcBoInfoFunc)(Pst *pst, DlRlcBOInfo *dlBoInfo);
542 uint8_t packMacSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo);
543 uint8_t macSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo);
544
545
546 /**********************************************************************
547   End of file
548  **********************************************************************/
549