1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
20 #define SCH_INST_START 1
21 #define SCH_MAX_INST 1
22 #define SCH_MU0_NUM_SLOTS 10
23 #define SCH_MU1_NUM_SLOTS 20
24 #define SCH_MU2_NUM_SLOTS 30
25 #define SCH_MU3_NUM_SLOTS 40
26 #define SCH_MU4_NUM_SLOTS 50
27 #define SCH_MAX_SFN 1024
28 #define MAX_NUM_RB 106 /* value for numerology 0 15Khz */
29 #define SCH_MIB_TRANS 80
30 #define SCH_NUM_SC_PRB 12 /* number of SCs in a PRB */
31 #define SCH_MAX_SSB_BEAM 4 /* since we are supporting only SCS=15KHz */
32 #define SCH_SCS_15KHZ 0 /* numerology 0 and 15Khz */
33 #define SCH_SYMBOL_PER_SLOT 14
34 #define SCH_SSB_NUM_SYMB 4
35 #define SCH_SSB_NUM_PRB 20
40 #define PUSCH_START_RB 15
41 #define PUCCH_NUM_PRB_FORMAT_0_1_4 1 /* number of PRBs in freq domain, spec 38.213 - 9.2.1 */
42 #define SI_RNTI 0xFFFF
44 #define DMRS_MAP_TYPE_A 1
45 #define NUM_DMRS_SYMBOLS 12
46 #define DMRS_ADDITIONAL_POS 2
47 #define SCH_DEFAULT_K1 1
52 #define RLC_HDR_SIZE 3 /* 3 bytes of RLC Header size */
53 #define MAC_HDR_SIZE 3 /* 3 bytes of MAC Header */
54 #define UL_GRANT_SIZE 224
56 typedef struct schCellCb SchCellCb;
57 typedef struct schUeCb SchUeCb;
70 SCH_UE_STATE_INACTIVE,
76 SCH_LC_STATE_INACTIVE,
82 * Structure holding LTE MAC's General Configuration information.
84 typedef struct schGenCb
86 uint8_t tmrRes; /*!< Timer resolution */
87 uint8_t startCellId; /*!< Starting Cell Id */
89 bool forceCntrlSrbBoOnPCel; /*!< value 1 means force scheduling
90 of RLC control BO and SRB BO on
91 PCell. val 0 means don't force*/
92 bool isSCellActDeactAlgoEnable; /*!< TRUE will enable activation/deactivation algo at Schd */
98 * scheduler allocationsfor DL per cell.
100 typedef struct schDlSlotInfo
102 uint16_t totalPrb; /*!< Number of RBs in the cell */
103 uint16_t assignedPrb[SCH_SYMBOL_PER_SLOT]; /*!< Num RBs and corresponding symbols allocated */
104 bool ssbPres; /*!< Flag to determine if SSB is present in this slot */
105 uint8_t ssbIdxSupported; /*!< Max SSB index */
106 SsbInfo ssbInfo[MAX_SSB_IDX]; /*!< SSB info */
107 bool sib1Pres; /*!< Flag to determine if SIB1 is present in this slot */
108 RarInfo *rarInfo; /*!< RAR info */
109 DlMsgInfo *dlMsgInfo; /*!< DL dedicated Msg info */
112 typedef struct schRaCb
119 * scheduler allocationsfor UL per cell.
121 typedef struct schUlSlotInfo
123 uint16_t totalPrb; /*!< Number of RBs in the cell */
124 uint16_t assignedPrb[SCH_SYMBOL_PER_SLOT]; /*!< Num RBs and corresponding symbols allocated */
125 uint8_t puschCurrentPrb; /* Current PRB for PUSCH allocation */
126 bool puschPres; /*!< PUSCH presence field */
127 SchPuschInfo *schPuschInfo; /*!< PUSCH info */
128 bool pucchPres; /*!< PUCCH presence field */
129 SchPucchInfo schPucchInfo; /*!< PUCCH info */
134 * BSR info per slot per UE.
136 typedef struct bsrInfo
138 uint8_t priority; /* CG priority */
139 uint32_t dataVol; /* Data volume requested in bytes */
142 typedef struct schLcCtxt
144 uint8_t lcId; // logical Channel ID
145 uint8_t lcp; // logical Channel Prioritization
150 typedef struct schDlCb
153 SchDlLcCtxt dlLcCtxt[MAX_NUM_LC];
156 typedef struct schUlLcCtxt
163 uint8_t pbr; // prioritisedBitRate
164 uint8_t bsd; // bucketSizeDuration
167 typedef struct schUlCb
170 SchUlLcCtxt ulLcCtxt[MAX_NUM_LC];
177 typedef struct schUeCb
185 BsrInfo bsrInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS];
192 * Cell Control block per cell.
194 typedef struct schCellCb
196 uint16_t cellId; /*!< Cell ID */
197 Inst instIdx; /*!< Index of the scheduler instance */
198 Inst macInst; /*!< Index of the MAC instance */
199 uint8_t numSlots; /*!< Number of slots in current frame */
200 SlotIndInfo slotInfo; /*!< SFN, Slot info being processed*/
201 SchDlSlotInfo **schDlSlotInfo; /*!< SCH resource allocations in DL */
202 SchUlSlotInfo **schUlSlotInfo; /*!< SCH resource allocations in UL */
203 SchCellCfg cellCfg; /*!< Cell ocnfiguration */
204 uint8_t ssbStartSymbArr[SCH_MAX_SSB_BEAM]; /*!<start symbol per SSB beam */
205 SchRaCb raCb[MAX_NUM_UE]; /*!< Rach Cb */
206 uint16_t numActvUe; /*!<Number of active UEs */
207 uint32_t actvUeBitMap; /*!<Bit map to find active UEs */
208 uint32_t boIndBitMap; /*!<Bit map to indicate UEs that have recevied BO */
209 SchUeCb ueCb[MAX_NUM_UE]; /*!<Pointer to UE contexts of this cell */
211 uint8_t numSlotsInPeriodicity; /*!< number of slots in configured periodicity and SCS */
212 uint32_t slotFrmtBitMap; /*!< 2 bits must be read together to determine D/U/S slots. 00-D, 01-U, 10-S */
213 uint32_t symbFrmtBitMap; /*!< 2 bits must be read together to determine D/U/S symbols. 00-D, 01-U, 10-S */
219 * Control block for sch
223 TskInit schInit; /*!< Task Init info */
224 SchGenCb genCfg; /*!< General Config info */
225 SchCellCb *cells[MAX_NUM_CELL]; /* Array to store cellCb ptr */
228 /* Declaration for scheduler control blocks */
229 SchCb schCb[SCH_MAX_INST];
231 /* function declarations */
232 uint8_t schBroadcastAlloc(SchCellCb *cell, DlBrdcstAlloc *dlBrdcstAlloc,uint16_t slot);
233 uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst inst);
234 uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst);
235 uint8_t schDlRsrcAllocMsg4(DlMsgAlloc *msg4Alloc, SchCellCb *cell, uint16_t slot);
236 uint16_t schCalcTbSize(uint16_t payLoadSize);
237 uint16_t schCalcNumPrb(uint16_t tbSize, uint16_t mcs, uint8_t numSymbols);
238 uint16_t schAllocPucchResource(SchCellCb *cell, uint16_t crnti, uint16_t slot);
239 uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst);
240 uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo puschInfo, DciInfo *dciInfo);
241 uint8_t schFillPuschAlloc(SchUeCb *ueCb, uint16_t pdcchSlot, uint32_t dataVol, SchPuschInfo *puschInfo);
242 uint8_t schDlRsrcAllocDlMsg(DlMsgAlloc *dlMsgAlloc, SchCellCb *cell, uint16_t crnti,
243 uint16_t accumalatedSize, uint16_t slot);
244 uint16_t schAccumalateLcBoSize(SchCellCb *cell, uint16_t ueIdx);
246 /**********************************************************************
248 **********************************************************************/