RAR_message
[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
25 /* selector */
26 #define MAC_SCH_LC_SELECTOR 0
27 #define MAC_SCH_TC_SELECTOR 1
28 #define MAC_SCH_LWLC_SELECTOR 2
29
30 /*macros*/
31 #define NO_SSB 0
32 #define SSB_TRANSMISSION 1
33 #define SSB_REPEAT 2
34 #define MAX_SSB_IDX 1 /* forcing it as 1 for now. Right value is 64 */
35
36 #define NO_SIB1 0
37 #define SIB1_TRANSMISSION 1
38 #define SIB1_REPITITION 2
39
40 #define MAX_NUM_PRG     1 /* max value should be later 275 */
41 #define MAX_DIG_BF_INTERFACES 0 /* max value should be later 255 */
42 #define MAX_CODEWORDS  1  /* max should be 2 */
43
44 /* Datatype in UL SCH Info */
45 #define SCH_DATATYPE_PUSCH 1
46 #define SCH_DATATYPE_PUSCH_UCI 2
47 #define SCH_DATATYPE_UCI 4
48 #define SCH_DATATYPE_SRS 8
49 #define SCH_DATATYPE_PRACH 16
50
51 /*structures*/
52
53
54 typedef enum
55 {
56         RSP_OK,
57         RSP_NOK
58 }schMacRsp;
59
60 typedef struct
61 {
62    uint32_t    ssbPbchPwr;       /* SSB block power */
63    uint8_t     scsCommon;           /* subcarrier spacing for common [0-3]*/
64    uint8_t     ssbOffsetPointA;  /* SSB sub carrier offset from point A */
65    SSBPeriod   ssbPeriod;        /* SSB Periodicity in msec */
66    uint8_t     ssbSubcOffset;    /* Subcarrier Offset(Kssb) */
67    uint32_t    nSSBMask[SSB_MASK_SIZE];      /* Bitmap for actually transmitted SSB. */
68 }SchSsbCfg;
69
70 typedef struct bwpCfg
71 {
72    uint8_t subcarrierSpacing;
73    uint8_t cyclicPrefix;
74    uint16_t BWPSize;
75    uint16_t BWPStart;
76 }BwpCfg;
77
78 typedef struct prg
79 {
80    uint16_t pmIdx;
81    uint16_t beamIdx[MAX_DIG_BF_INTERFACES];
82 } Prg;
83
84 typedef struct beamformingInfo
85 {
86    uint16_t numPrgs;
87    uint16_t prgSize;
88    uint8_t  digBfInterfaces;
89    Prg  prg[MAX_NUM_PRG];
90 } BeamformingInfo;
91
92 /* SIB1 PDSCH structures */
93
94 typedef struct codewordinfo
95 {
96    uint16_t targetCodeRate;
97    uint8_t  qamModOrder;
98    uint8_t  mcsIndex;
99    uint8_t  mcsTable;
100    uint8_t  rvIndex;
101    uint32_t tbSize;
102 } CodewordInfo;
103
104 typedef struct dmrsInfo
105 {
106    uint16_t dlDmrsSymbPos;
107    uint8_t  dmrsConfigType;
108    uint16_t dlDmrsScramblingId;
109    uint8_t  scid;
110    uint8_t  numDmrsCdmGrpsNoData;
111    uint16_t dmrsPorts;
112 } DmrsInfo;
113
114 typedef struct pdschFreqAlloc
115 {
116    uint8_t  resourceAlloc;
117    /* since we are using type-1, hence rbBitmap excluded */
118    uint16_t rbStart;
119    uint16_t rbSize;
120    uint8_t  vrbPrbMapping;
121 } PdschFreqAlloc;
122
123 typedef struct pdschTimeAlloc
124 {
125    uint8_t rowIndex;
126    uint8_t startSymbolIndex;
127    uint8_t numSymbols;
128 } PdschTimeAlloc;
129
130 typedef struct txPowerPdschInfo
131 {
132    uint8_t powerControlOffset;
133    uint8_t powerControlOffsetSS;
134 } TxPowerPdschInfo;
135
136 typedef struct pdschCfg
137 {
138    uint16_t pduBitmap;
139    uint16_t rnti;
140    uint16_t pduIndex;
141    BwpCfg pdschBwpCfg;
142    uint8_t numCodewords;
143    CodewordInfo codeword[MAX_CODEWORDS];
144    uint16_t dataScramblingId;
145    uint8_t  numLayers;
146    uint8_t  transmissionScheme;
147    uint8_t  refPoint;
148    DmrsInfo dmrs;
149    PdschFreqAlloc freqAlloc;
150    PdschTimeAlloc timeAlloc;
151    BeamformingInfo beamPdschInfo;
152    TxPowerPdschInfo txPdschPower;
153 } PdschCfg;
154 /* SIB1 PDSCH structures end */
155
156 /* SIB1 interface structure */
157
158 typedef struct coresetCfg
159 {
160    uint8_t coreSet0Size;
161    uint8_t startSymbolIndex;
162    uint8_t durationSymbols;
163    uint8_t freqDomainResource[6];
164    uint8_t cceRegMappingType;
165    uint8_t regBundleSize;
166    uint8_t interleaverSize;
167    uint8_t coreSetType;
168    uint16_t shiftIndex;
169    uint8_t precoderGranularity;
170    uint8_t cceIndex;
171    uint8_t aggregationLevel;
172 } CoresetCfg;
173
174 typedef struct txPowerPdcchInfo
175 {
176    uint8_t powerValue;
177    uint8_t powerControlOffsetSS;
178 } TxPowerPdcchInfo;
179
180 typedef struct dlDCI
181 {
182    uint16_t rnti;
183    uint16_t scramblingId;
184    uint16_t scramblingRnti;
185    uint8_t cceIndex;
186    uint8_t aggregLevel;
187    BeamformingInfo beamPdcchInfo;
188    TxPowerPdcchInfo txPdcchPower;
189    PdschCfg     *pdschCfg;
190 } DlDCI;
191
192 typedef struct pdcchCfg
193 {
194    BwpCfg pdcchBwpCfg;
195    /* coreset-0 configuration */
196    CoresetCfg coreset0Cfg;
197
198    uint16_t numDlDci;
199    DlDCI    dci; /* as of now its only one DCI, later it will be numDlCi */
200 } PdcchCfg;
201 /* end of SIB1 PDCCH structures */
202
203 typedef struct
204 {
205    /* parameters recieved from DU-APP */
206    uint16_t sib1PduLen;
207    uint16_t sib1NewTxPeriod;
208    uint16_t sib1RepetitionPeriod;
209    uint8_t  coresetZeroIndex;     /* derived from 4 LSB of pdcchSib1 present in MIB */
210    uint8_t  searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */
211    uint16_t sib1Mcs;
212         
213         /* parameters derived in scheduler */
214         uint8_t n0;
215    PdcchCfg sib1PdcchCfg;
216    PdschCfg sib1PdschCfg;
217 }SchSib1Cfg;
218
219 typedef struct schRachCfg
220 {
221    uint8_t      prachCfgIdx; /* PRACH config idx */
222    uint8_t      prachSubcSpacing; /* Subcarrier spacing of RACH */
223         uint16_t     msg1FreqStart;     /* Msg1-FrequencyStart */
224         uint8_t      msg1Fdm;             /* PRACH FDM (1,2,4,8) */
225    uint16_t     rootSeqIdx;        /* Root sequence index */
226    uint8_t      numRootSeq;        /* Number of root sequences required for FD */
227    uint16_t     k1;                /* Frequency Offset for each FD */
228    uint8_t      ssbPerRach;          /* SSB per RACH occassion */
229    uint8_t      prachMultCarrBand;    /* Presence of Multiple carriers in Band */
230         uint8_t      raContResTmr;        /* RA Contention Resoultion Timer */
231         uint8_t      rsrpThreshSsb;       /* RSRP Threshold SSB */
232    uint8_t      raRspWindow;         /* RA Response Window */
233 }SchRachCfg;
234
235 typedef struct schCellCfg
236 {
237    uint16_t    cellId;     /* Cell Id */
238    uint16_t    phyCellId;  /* Physical cell id */
239         uint8_t     bandwidth;  /* Supported B/W */
240    DuplexMode  dupMode;    /* Duplex type: TDD/FDD */
241         SchSsbCfg   ssbSchCfg;  /* SSB config */
242         SchSib1Cfg  sib1SchCfg; /* SIB1 config */
243    SchRachCfg  schRachCfg; /* PRACH config */
244 }SchCellCfg;
245
246 typedef struct schCellCfgCfm
247 {
248    U16         cellId;     /* Cell Id */
249    schMacRsp   rsp;   
250 }SchCellCfgCfm;
251
252 typedef struct timeDomainAlloc
253 {
254    uint16_t ssbStartSymbIdx;
255         uint16_t ssbSymbolDuration;
256 }TimeDomainAlloc;
257
258 typedef struct freqDomainAlloc
259 {
260    uint16_t ssbStartPrbIdx;
261    uint16_t ssbPrbDuration;
262 }FreqDomainAlloc;
263
264 typedef struct ssbInfo
265 {
266    uint8_t ssbIdx;          /* SSB Index */
267         TimeDomainAlloc tdAlloc; /* Time domain allocation */
268         FreqDomainAlloc fdAlloc; /* Freq domain allocation */
269 }SsbInfo;
270
271 typedef struct sib1AllocInfo
272 {
273    PdcchCfg sib1PdcchCfg;
274    PdschCfg sib1PdschCfg;
275 } Sib1AllocInfo;
276
277 typedef struct prachSchInfo
278 {
279         uint8_t  numPrachOcas;   /* Num Prach Ocassions */
280    uint8_t  prachFormat;    /* PRACH Format */
281    uint8_t  numRa;          /* Freq domain ocassion */
282    uint8_t  prachStartSymb; /* Freq domain ocassion */
283 }PrachSchInfo;
284
285 /* Interface structure signifying DL broadcast allocation for SSB, SIB1 */
286 typedef struct dlBrdcstAlloc
287 {
288         /* Ssb transmission is determined as follows:
289          * 0 : No tranamission
290          * 1 : SSB Transmission
291          * 2 : SSB Repetition */
292         uint8_t ssbTrans;
293         uint8_t ssbIdxSupported;
294         SsbInfo ssbInfo[MAX_SSB_IDX];
295         /* Sib1 transmission is determined as follows:
296          * 0 : No tranamission
297          * 1 : SIB1 Transmission
298          * 2 : SIB1 Repetition */
299         U8 sib1Trans;
300         Sib1AllocInfo sib1Alloc;
301 }DlBrdcstAlloc;
302
303 typedef struct rarInfo
304 {
305    uint16_t raRnti;
306         uint8_t  RAPID;
307         uint16_t ta;
308         uint16_t msg3StartRb;
309         uint8_t  msg3NumRb;
310         uint16_t tcrnti;
311         uint8_t rarPdu[8];
312         uint8_t rarPduLen;
313 }RarInfo;
314
315 typedef struct rarAlloc
316 {
317    RarInfo rarInfo;
318    PdcchCfg rarPdcchCfg;
319    PdschCfg rarPdschCfg;
320 }RarAlloc;
321
322 typedef struct dlAlloc
323 {
324    uint16_t cellId;  /* Cell Id */
325         SlotIndInfo slotIndInfo; /* Slot Info: sfn, slot number */
326
327         /* Allocation for broadcast messages */
328    uint8_t isBroadcastPres;
329         DlBrdcstAlloc brdcstAlloc;
330
331         /* Allocation for RAR message */
332         uint8_t isRarPres;
333         RarAlloc rarAlloc;
334 }DlAlloc;
335 typedef struct ulSchInfo
336 {
337    uint16_t      cellId;         /* Cell Id */
338         SlotIndInfo   slotIndInfo;    /* Slot Info: sfn, slot number */
339         uint8_t       dataType;       /* Type of info being scheduled */
340         PrachSchInfo  prachSchInfo;   /* Prach scheduling info */
341 }UlSchInfo;
342
343 typedef struct rachIndInfo
344 {
345    uint16_t    cellId;
346    uint16_t    crnti;
347    SlotIndInfo timingInfo;
348    uint8_t     slotIdx;
349    uint8_t     symbolIdx;
350    uint8_t     freqIdx;
351    uint8_t     preambleIdx;
352    uint16_t    timingAdv;
353 }RachIndInfo;
354
355 /* function pointers */
356
357 typedef int (*SchCellCfgCfmFunc)    ARGS((
358    Pst            *pst,           /* Post Structure */                         
359    SchCellCfgCfm  *schCellCfgCfm  /* Cell Cfg Cfm */
360 ));
361
362 typedef int (*SchCellCfgFunc)    ARGS((
363    Pst            *pst,           /* Post Structure */                         
364    SchCellCfg  *schCellCfg     /* Cell Cfg  */
365 ));
366
367 typedef int (*SchMacDlAllocFunc)     ARGS((                     
368    Pst            *pst,       /* Post Structure */                         
369    DlAlloc        *dlAlloc    /* dl allocation Info */                      
370 ));
371
372 typedef int (*SchMacUlSchInfoFunc)     ARGS((                     
373    Pst            *pst,           /* Post Structure */                         
374    UlSchInfo      *ulSchInfo    /* UL Sch  Info */                      
375 ));
376
377 /* function declarations */
378 int packMacSchSlotInd(Pst *pst, SlotIndInfo *slotInd);
379 int packSchMacDlAlloc(Pst *pst, DlAlloc  *dlAlloc);
380 int packSchMacUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo);
381 EXTERN int packSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
382 EXTERN int packSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
383
384 EXTERN int MacProcDlAlloc(Pst *pst, DlAlloc *dlAlloc);
385 EXTERN int MacProcSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
386 EXTERN int MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
387 EXTERN int SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg);
388 EXTERN int schActvInit(Ent entity, Inst instId, Region region, Reason reason);
389 EXTERN S16 SchSendCfgCfm(Pst *pst, RgMngmt *cfm);
390 EXTERN int MacProcUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo);
391 typedef int (*MacSchRachIndFunc)(Pst *pst, RachIndInfo *rachInd);
392 int packMacSchRachInd(Pst *pst, RachIndInfo *rachInd);
393 int macSchRachInd(Pst *pst, RachIndInfo *rachInd);
394
395 /**********************************************************************
396   End of file
397  **********************************************************************/
398