RAR_message
[o-du/l2.git] / src / 5gnrsch / sch.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 /* macros */
20 #define SCH_INST_START 1
21 #define SCH_MAX_CELLS 1
22 #define SCH_MAX_INST 1
23 #define SCH_NUM_SLOTS 10 /*forcing this to 10 */
24 #define SCH_MAX_SFN 1024
25 #define MAX_NUM_RB 106 /* value for numerology 0 15Khz */
26 #define SCH_MIB_TRANS 80 
27 #define SCH_NUM_SC_PRB 12 /* number of SCs in a PRB */
28 #define SCH_MAX_SSB_BEAM 4 /* since we are supporting only SCS=15KHz */
29 #define SCH_SCS_15KHZ 0 /* numerology 0 and 15Khz */
30 #define SCH_SYMBOL_PER_SLOT 14
31 #define SCH_SSB_SYMB_DURATION 4
32 #define SCH_SSB_PRB_DURATION 20
33 #define SCH_MEM_REGION     4
34 #define SCH_POOL           1
35 #define SCHED_DELTA 1
36 #define SCH_MAX_UE 512
37 #define SI_RNTI 0xFFFF
38 #define P_RNIT  0xFFFE
39
40 /* allocate and zero out a static buffer */
41 #define SCH_ALLOC(_datPtr, _size)                                \
42 {                                                               \
43    S16 _ret;                                                    \
44    _ret = SGetSBuf(SCH_MEM_REGION, SCH_POOL,                  \
45                     (Data **)&_datPtr, _size);                  \
46    if(_ret == ROK)                                              \
47       cmMemset((U8*)_datPtr, 0, _size);                         \
48    else                                                         \
49       _datPtr = NULLP;                                          \
50 }
51
52 /* free a static buffer */
53 #define SCH_FREE(_datPtr, _size)                                 \
54    if(_datPtr)                                                  \
55       SPutSBuf(SCH_MEM_REGION, SCH_POOL,                      \
56          (Data *)_datPtr, _size);
57
58
59 #define SCH_FILL_RSP_PST(_rspPst, _inst)\
60 {                                  \
61    _rspPst.srcProcId = SFndProcId(); \
62    _rspPst.dstProcId = SFndProcId();\
63    _rspPst.srcEnt    = ENTRG;\
64    _rspPst.dstEnt    = ENTRG;\
65    _rspPst.srcInst   = 1;\
66    _rspPst.dstInst   = 0;\
67         _rspPst.selector  = MAC_SELECTOR_TC;\
68 }       
69
70 /**
71   * @brief
72   * Structure holding LTE MAC's General Configuration information.
73   */
74 typedef struct schGenCb
75 {
76    uint8_t         tmrRes;           /*!< Timer resolution */
77    uint8_t         startCellId;      /*!< Starting Cell Id */
78 #ifdef LTE_ADV
79    bool            forceCntrlSrbBoOnPCel; /*!< value 1 means force scheduling
80                                                of RLC control BO and SRB BO on
81                                                PCell. val 0 means don't force*/
82    bool            isSCellActDeactAlgoEnable; /*!< TRUE will enable activation/deactivation algo at Schd */
83 #endif
84 }SchGenCb;
85
86 /**
87   * @brief
88   * scheduler allocationsfor DL per cell.
89   */
90 typedef struct schDlAlloc
91 {
92         uint16_t    totalPrb;  /*!< Number of RBs in the cell */
93         uint16_t    assignedPrb[SCH_SYMBOL_PER_SLOT]; /*!< Num RBs and corresponding symbols allocated */
94    bool        ssbPres;    /*!< Flag to determine if SSB is present in this slot */
95    uint8_t     ssbIdxSupported;  /*!< Max SSB index */
96         SsbInfo     ssbInfo[MAX_SSB_IDX]; /*!< SSB info */
97         bool        sib1Pres;
98         bool        rarPres;
99         RarInfo     rarInfo;
100 }SchDlAlloc;
101
102 typedef struct schRaCb
103 {
104    uint16_t tcrnti;
105 }SchRaCb;
106
107 /**
108   * @brief
109   * scheduler allocationsfor UL per cell.
110   */
111 typedef struct schUlAlloc
112 {
113         uint16_t    totalPrb;  /*!< Number of RBs in the cell */
114         uint16_t    assignedPrb[SCH_SYMBOL_PER_SLOT]; /*!< Num RBs and corresponding symbols allocated */
115         uint8_t     prachStartSymb; /*!< Start symbol for PRACH */
116 }SchUlAlloc;
117
118 /**
119   * @brief
120   * Cell Control block per cell.
121   */
122 typedef struct schCellCb
123 {
124    uint16_t      cellId;           /*!< Cell ID */
125    Inst          instIdx;          /*!< Index of the scheduler instance */
126    Inst          macInst;          /*!< Index of the MAC instance */
127         uint8_t       numSlots;         /*!< Number of slots in current frame */
128    SlotIndInfo   slotInfo;         /*!< SFN, Slot info being processed*/
129    SchDlAlloc    *dlAlloc[SCH_NUM_SLOTS]; /*!< SCH resource allocations in DL */
130    SchUlAlloc    *ulAlloc[SCH_NUM_SLOTS]; /*!< SCH resource allocations in UL */
131         SchCellCfg    cellCfg;                /*!< Cell ocnfiguration */
132         SchRaCb       raCb[SCH_MAX_UE];
133 }SchCellCb;
134
135 /**
136   * @brief
137   * Control block for sch
138   */
139 typedef struct schCb
140 {
141    TskInit       schInit;              /*!< Task Init info */
142    SchGenCb      genCfg;                 /*!< General Config info */
143    SchCellCb     *cells[SCH_MAX_CELLS];  /* Array to store cellCb ptr */  
144 }SchCb;
145
146 /* Declaration for scheduler control blocks */
147 SchCb schCb[SCH_MAX_INST];
148
149 /* function declarations */
150 uint8_t schBroadcastAlloc(SchCellCb *cell, DlBrdcstAlloc *dlBrdcstAlloc,uint16_t slot);
151 uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst inst);
152 uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst);
153
154
155
156 /**********************************************************************
157          End of file
158 **********************************************************************/