MAC SCH interface for RACH config
[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
23 /* selector */
24 #define MAC_SCH_LC_SELECTOR 0
25 #define MAC_SCH_TC_SELECTOR 1
26 #define MAC_SCH_LWLC_SELECTOR 2
27
28 /*macros*/
29 #define NO_SSB 0
30 #define SSB_TRANSMISSION 1
31 #define SSB_REPEAT 2
32 #define MAX_SSB_IDX 1 /* forcing it as 1 for now. Right value is 64 */
33
34 #define NO_SIB1 0
35 #define SIB1_TRANSMISSION 1
36 #define SIB1_REPITITION 2
37
38 #define MAX_NUM_PRG     1 /* max value should be later 275 */
39 #define MAX_DIG_BF_INTERFACES 0 /* max value should be later 255 */
40 #define MAX_CODEWORDS  1  /* max should be 2 */
41
42 /*structures*/
43
44
45 typedef enum
46 {
47         RSP_OK,
48         RSP_NOK
49 }schMacRsp;
50
51 typedef struct
52 {
53    uint32_t    ssbPbchPwr;       /* SSB block power */
54    uint8_t     scsCommon;           /* subcarrier spacing for common [0-3]*/
55    uint8_t     ssbOffsetPointA;  /* SSB sub carrier offset from point A */
56    SSBPeriod   ssbPeriod;        /* SSB Periodicity in msec */
57    uint8_t     ssbSubcOffset;    /* Subcarrier Offset(Kssb) */
58    uint32_t    nSSBMask[SSB_MASK_SIZE];      /* Bitmap for actually transmitted SSB. */
59 }SchSsbCfg;
60
61 /* SIB1 interface structure */
62 typedef struct bwpCfg
63 {
64    uint16_t BWPSize;
65    uint16_t BWPStart;
66 }BwpCfg;
67
68 typedef struct coresetCfg
69 {
70    uint8_t startSymbolIndex;
71    uint8_t durationSymbols;
72    uint8_t freqDomainResource[6];
73    uint8_t cceRegMappingType;
74    uint8_t regBundleSize;
75    uint8_t interleaverSize;
76    uint8_t coreSetType;
77    uint16_t shiftIndex;
78    uint8_t precoderGranularity;
79    uint8_t cceIndex;
80    uint8_t aggregationLevel;
81 } CoresetCfg;
82
83 typedef struct prg
84 {
85    uint16_t pmIdx;
86    uint16_t beamIdx[MAX_DIG_BF_INTERFACES];
87 } Prg;
88
89 typedef struct beamformingInfo
90 {
91    uint16_t numPrgs;
92    uint16_t prgSize;
93    uint8_t  digBfInterfaces;
94    Prg  prg[MAX_NUM_PRG];
95 } BeamformingInfo;
96
97 typedef struct txPowerPdcchInfo
98 {
99    uint8_t powerValue;
100    uint8_t powerControlOffsetSS;
101 } TxPowerPdcchInfo;
102
103 typedef struct dlDCI
104 {
105    uint16_t rnti;
106    uint16_t scramblingId;
107    uint16_t scramblingRnti;
108    uint8_t cceIndex;
109    uint8_t aggregLevel;
110    BeamformingInfo beamPdcchInfo;
111    TxPowerPdcchInfo txPdcchPower;
112 } DlDCI;
113
114 typedef struct sib1PdcchCfg
115 {
116    BwpCfg sib1PdcchBwpCfg;
117
118    uint8_t subcarrierSpacing;
119    uint8_t cyclicPrefix;
120
121    /* coreset-0 configuration */
122    CoresetCfg sib1Coreset0Cfg;
123
124    uint16_t numDlDci;
125    DlDCI    sib1DlDci; /* as of now its only one DCI, later it will be numDlCi */
126 } Sib1PdcchCfg;
127 /* end of SIB1 PDCCH structures */
128
129 /* SIB1 PDSCH structures */
130
131 typedef struct codewordinfo
132 {
133    uint16_t targetCodeRate;
134    uint8_t  qamModOrder;
135    uint8_t  mcsIndex;
136    uint8_t  mcsTable;
137    uint8_t  rvIndex;
138    uint32_t tbSize;
139 } CodewordInfo;
140
141 typedef struct dmrsInfo
142 {
143    uint16_t dlDmrsSymbPos;
144    uint8_t  dmrsConfigType;
145    uint16_t dlDmrsScramblingId;
146    uint8_t  scid;
147    uint8_t  numDmrsCdmGrpsNoData;
148    uint16_t dmrsPorts;
149 } DmrsInfo;
150
151 typedef struct pdschFreqAlloc
152 {
153    uint8_t  resourceAlloc;
154    /* since we are using type-1, hence rbBitmap excluded */
155    uint16_t rbStart;
156    uint16_t rbSize;
157    uint8_t  vrbPrbMapping;
158 } PdschFreqAlloc;
159
160 typedef struct pdschTimeAlloc
161 {
162    uint8_t startSymbolIndex;
163    uint8_t numSymbols;
164 } PdschTimeAlloc;
165
166 typedef struct txPowerPdschInfo
167 {
168    uint8_t powerControlOffset;
169    uint8_t powerControlOffsetSS;
170 } TxPowerPdschInfo;
171
172 typedef struct sib1PdschCfg
173 {
174    uint16_t pduBitmap;
175    uint16_t rnti;
176    uint16_t pduIndex;
177    BwpCfg sib1PdschBwpCfg;
178    uint8_t numCodewords;
179    CodewordInfo codeword[MAX_CODEWORDS];
180    uint16_t dataScramblingId;
181    uint8_t  numLayers;
182    uint8_t  transmissionScheme;
183    uint8_t  refPoint;
184    DmrsInfo dmrs;
185    PdschFreqAlloc sib1FreqAlloc;
186    PdschTimeAlloc sib1TimeAlloc;
187    BeamformingInfo beamPdschInfo;
188    TxPowerPdschInfo txPdschPower;
189 } Sib1PdschCfg;
190 /* SIB1 PDSCH structures end */
191
192 typedef struct
193 {
194    /* parameters recieved from DU-APP */
195    uint16_t sib1PduLen;
196    uint16_t sib1NewTxPeriod;
197    uint16_t sib1RepetitionPeriod;
198    uint8_t  coresetZeroIndex;     /* derived from 4 LSB of pdcchSib1 present in MIB */
199    uint8_t  searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */
200    uint16_t sib1Mcs;
201         
202         /* parameters derived in scheduler */
203         uint8_t n0;
204    Sib1PdcchCfg sib1PdcchCfg;
205    Sib1PdschCfg sib1PdschCfg;
206 }SchSib1Cfg;
207
208 typedef struct schRachCfg
209 {
210    uint8_t      prachCfgIdx; /* PRACH config idx */
211    uint8_t      prachSubcSpacing; /* Subcarrier spacing of RACH */
212    uint8_t      prachSeqLen;  /* Support for PRACH long/short format */
213         uint16_t     msg1FreqStart;     /* Msg1-FrequencyStart */
214         uint8_t      msg1Fdm;             /* PRACH FDM (1,2,4,8) */
215    uint8_t      maxPrachOcassionsInSlot; /* Number of PRACH ocassions per slot */
216    uint8_t      numPrachFdOccasions; /*Number of PRACH ocassions in freq domain */
217    uint16_t     rootSeqIdx;        /* Root sequence index */
218    uint8_t      numRootSeq;        /* Number of root sequences required for FD */
219    uint16_t     k1;                /* Frequency Offset for each FD */
220    uint8_t      ssbPerRach;          /* SSB per RACH occassion */
221    uint8_t      prachMultCarrBand;    /* Presence of Multiple carriers in Band */
222         uint8_t      raContResTmr;        /* RA Contention Resoultion Timer */
223         uint8_t      rsrpThreshSsb;       /* RSRP Threshold SSB */
224    uint8_t      raRspWindow;         /* RA Response Window */
225 }SchRachCfg;
226
227 typedef struct schCellCfg
228 {
229    uint16_t    cellId;     /* Cell Id */
230    uint16_t    phyCellId;  /* Physical cell id */
231         uint8_t     bandwidth;  /* Supported B/W */
232    DuplexMode  dupMode;    /* Duplex type: TDD/FDD */
233         SchSsbCfg   ssbSchCfg;  /* SSB config */
234         SchSib1Cfg  sib1SchCfg; /* SIB1 config */
235    SchRachCfg  schRachCfg; /* PRACH config */
236 }SchCellCfg;
237
238 typedef struct schCellCfgCfm
239 {
240    U16         cellId;     /* Cell Id */
241    schMacRsp   rsp;   
242 }SchCellCfgCfm;
243
244 typedef struct timeDomainAlloc
245 {
246    uint16_t ssbStartSymbIdx;
247         uint16_t ssbSymbolDuration;
248 }TimeDomainAlloc;
249
250 typedef struct freqDomainAlloc
251 {
252    uint16_t ssbStartPrbIdx;
253    uint16_t ssbPrbDuration;
254 }FreqDomainAlloc;
255
256 typedef struct ssbInfo
257 {
258    uint8_t ssbIdx;          /* SSB Index */
259         TimeDomainAlloc tdAlloc; /* Time domain allocation */
260         FreqDomainAlloc fdAlloc; /* Freq domain allocation */
261 }SsbInfo;
262
263 typedef struct sib1AllocInfo
264 {
265    Sib1PdcchCfg sib1PdcchCfg;
266    Sib1PdschCfg sib1PdschCfg;
267 } Sib1AllocInfo;
268
269 /* Interface structure signifying DL broadcast allocation for SSB, SIB1 */
270 typedef struct dlBrdcstAlloc
271 {
272    uint16_t cellId;  /* Cell Id */
273         SlotIndInfo slotIndInfo; /* Slot Info: sfn, slot number */
274         /* Ssb transmission is determined as follows:
275          * 0 : No tranamission
276          * 1 : SSB Transmission
277          * 2 : SSB Repetition */
278         uint8_t ssbTrans;
279         uint8_t ssbIdxSupported;
280         SsbInfo ssbInfo[MAX_SSB_IDX];
281         /* Sib1 transmission is determined as follows:
282          * 0 : No tranamission
283          * 1 : SIB1 Transmission
284          * 2 : SIB1 Repetition */
285         U8 sib1Trans;
286         Sib1AllocInfo sib1Alloc;
287 }DlBrdcstAlloc;
288
289 /* function pointers */
290
291 typedef int (*SchMacDlBrdcstAllocFunc)     ARGS((                     
292    Pst            *pst,           /* Post Structure */                         
293    DlBrdcstAlloc  *dlBrdcstAlloc    /* slot ind Info */                      
294 ));
295
296 typedef int (*SchCellCfgCfmFunc)    ARGS((
297    Pst            *pst,           /* Post Structure */                         
298    SchCellCfgCfm  *schCellCfgCfm  /* Cell Cfg Cfm */
299 ));
300
301 typedef int (*SchCellCfgFunc)    ARGS((
302    Pst            *pst,           /* Post Structure */                         
303    SchCellCfg  *schCellCfg     /* Cell Cfg  */
304 ));
305 /* function declarations */
306 int packMacSchSlotInd(Pst *pst, SlotIndInfo *slotInd);
307 int packSchMacDlBrdcstAlloc(Pst *pst, DlBrdcstAlloc  *dlBrdcstAlloc);
308 EXTERN int packSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
309 EXTERN int packSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
310
311 EXTERN int MacProcDlBrdcstAlloc(Pst *pst, DlBrdcstAlloc *dlBrdcstAlloc);
312 EXTERN int MacProcSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
313 EXTERN int MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
314 EXTERN int SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg);
315 EXTERN int schActvInit(Ent entity, Inst instId, Region region, Reason reason);
316 EXTERN S16 SchSendCfgCfm(Pst *pst, RgMngmt *cfm);
317
318 /**********************************************************************
319   End of file
320  **********************************************************************/
321