PRACH ocassion tracking
[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_BRDCST_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 sib1PdschCfg
137 {
138    uint16_t pduBitmap;
139    uint16_t rnti;
140    uint16_t pduIndex;
141    BwpCfg sib1PdschBwpCfg;
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 sib1FreqAlloc;
150    PdschTimeAlloc sib1TimeAlloc;
151    BeamformingInfo beamPdschInfo;
152    TxPowerPdschInfo txPdschPower;
153 } Sib1PdschCfg;
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    Sib1PdschCfg     *pdschCfg;
190 } DlDCI;
191
192 typedef struct sib1PdcchCfg
193 {
194    BwpCfg sib1PdcchBwpCfg;
195    /* coreset-0 configuration */
196    CoresetCfg sib1Coreset0Cfg;
197
198    uint16_t numDlDci;
199    DlDCI    sib1DlDci; /* as of now its only one DCI, later it will be numDlCi */
200 } Sib1PdcchCfg;
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    Sib1PdcchCfg sib1PdcchCfg;
216    Sib1PdschCfg 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    Sib1PdcchCfg sib1PdcchCfg;
274    Sib1PdschCfg 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    uint16_t cellId;  /* Cell Id */
289         SlotIndInfo slotIndInfo; /* Slot Info: sfn, slot number */
290         /* Ssb transmission is determined as follows:
291          * 0 : No tranamission
292          * 1 : SSB Transmission
293          * 2 : SSB Repetition */
294         uint8_t ssbTrans;
295         uint8_t ssbIdxSupported;
296         SsbInfo ssbInfo[MAX_SSB_IDX];
297         /* Sib1 transmission is determined as follows:
298          * 0 : No tranamission
299          * 1 : SIB1 Transmission
300          * 2 : SIB1 Repetition */
301         U8 sib1Trans;
302         Sib1AllocInfo sib1Alloc;
303 }DlBrdcstAlloc;
304
305 /* Interface structure signifying DL broadcast allocation for SSB, SIB1 */
306 typedef struct ulSchInfo
307 {
308    uint16_t      cellId;         /* Cell Id */
309         SlotIndInfo   slotIndInfo;    /* Slot Info: sfn, slot number */
310         uint8_t       dataType;       /* Type of info being scheduled */
311         PrachSchInfo  prachSchInfo;   /* Prach scheduling info */
312 }UlSchInfo;
313
314 /* function pointers */
315
316 typedef int (*SchCellCfgCfmFunc)    ARGS((
317    Pst            *pst,           /* Post Structure */                         
318    SchCellCfgCfm  *schCellCfgCfm  /* Cell Cfg Cfm */
319 ));
320
321 typedef int (*SchCellCfgFunc)    ARGS((
322    Pst            *pst,           /* Post Structure */                         
323    SchCellCfg  *schCellCfg     /* Cell Cfg  */
324 ));
325
326 typedef int (*SchMacDlBrdcstAllocFunc)     ARGS((                     
327    Pst            *pst,           /* Post Structure */                         
328    DlBrdcstAlloc  *dlBrdcstAlloc    /* DL Broadcast Info */                      
329 ));
330
331 typedef int (*SchMacUlSchInfoFunc)     ARGS((                     
332    Pst            *pst,           /* Post Structure */                         
333    UlSchInfo      *ulSchInfo    /* UL Sch  Info */                      
334 ));
335
336 /* function declarations */
337 int packMacSchSlotInd(Pst *pst, SlotIndInfo *slotInd);
338 int packSchMacDlBrdcstAlloc(Pst *pst, DlBrdcstAlloc  *dlBrdcstAlloc);
339 int packSchMacUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo);
340 EXTERN int packSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
341 EXTERN int packSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
342
343 EXTERN int MacProcDlBrdcstAlloc(Pst *pst, DlBrdcstAlloc *dlBrdcstAlloc);
344 EXTERN int MacProcSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
345 EXTERN int MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
346 EXTERN int SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg);
347 EXTERN int schActvInit(Ent entity, Inst instId, Region region, Reason reason);
348 EXTERN S16 SchSendCfgCfm(Pst *pst, RgMngmt *cfm);
349 EXTERN int MacProcUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo);
350
351 /**********************************************************************
352   End of file
353  **********************************************************************/
354