PHY_DELTA changes
[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 BO_DELTA 1
37 #define RAR_DELAY   2
38 #define SCH_MAX_UE  1
39 #define PUSCH_START_RB 15
40 #define SI_RNTI 0xFFFF
41 #define P_RNTI  0xFFFE
42
43 #define CRC_FAILED 0
44 #define CRC_PASSED 1
45
46 /* allocate and zero out a static buffer */
47 #define SCH_ALLOC(_datPtr, _size)                                \
48 {                                                               \
49    S16 _ret;                                                    \
50    _ret = SGetSBuf(SCH_MEM_REGION, SCH_POOL,                  \
51                     (Data **)&_datPtr, _size);                  \
52    if(_ret == ROK)                                              \
53       cmMemset((U8*)_datPtr, 0, _size);                         \
54    else                                                         \
55       _datPtr = NULLP;                                          \
56 }
57
58 /* free a static buffer */
59 #define SCH_FREE(_datPtr, _size)                                 \
60    if(_datPtr)                                                  \
61       SPutSBuf(SCH_MEM_REGION, SCH_POOL,                      \
62          (Data *)_datPtr, _size);
63
64 #define SCH_FILL_RSP_PST(_rspPst, _inst)\
65 {                                  \
66    _rspPst.srcProcId = SFndProcId(); \
67    _rspPst.dstProcId = SFndProcId();\
68    _rspPst.srcEnt    = ENTRG;\
69    _rspPst.dstEnt    = ENTRG;\
70    _rspPst.srcInst   = 1;\
71    _rspPst.dstInst   = 0;\
72         _rspPst.selector  = MAC_SELECTOR_TC;\
73 }       
74 extern uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst);
75 /**
76   * @brief
77   * Structure holding LTE MAC's General Configuration information.
78   */
79 typedef struct schGenCb
80 {
81    uint8_t         tmrRes;           /*!< Timer resolution */
82    uint8_t         startCellId;      /*!< Starting Cell Id */
83 #ifdef LTE_ADV
84    bool            forceCntrlSrbBoOnPCel; /*!< value 1 means force scheduling
85                                                of RLC control BO and SRB BO on
86                                                PCell. val 0 means don't force*/
87    bool            isSCellActDeactAlgoEnable; /*!< TRUE will enable activation/deactivation algo at Schd */
88 #endif
89 }SchGenCb;
90
91 /**
92   * @brief
93   * scheduler allocationsfor DL per cell.
94   */
95 typedef struct schDlSlotInfo
96 {
97         uint16_t    totalPrb;  /*!< Number of RBs in the cell */
98         uint16_t    assignedPrb[SCH_SYMBOL_PER_SLOT]; /*!< Num RBs and corresponding symbols allocated */
99    bool        ssbPres;    /*!< Flag to determine if SSB is present in this slot */
100    uint8_t     ssbIdxSupported;  /*!< Max SSB index */
101         SsbInfo     ssbInfo[MAX_SSB_IDX]; /*!< SSB info */
102         bool        sib1Pres;
103         //bool        rarPres;
104         RarInfo     *rarInfo;
105    Msg4Info    *msg4Info;
106 }SchDlSlotInfo;
107
108 typedef struct schRaCb
109 {
110    uint16_t tcrnti;
111 }SchRaCb;
112
113 /**
114   * @brief
115   * scheduler allocationsfor UL per cell.
116   */
117 typedef struct schUlSlotInfo
118 {
119         uint16_t     totalPrb;  /*!< Number of RBs in the cell */
120         uint16_t     assignedPrb[SCH_SYMBOL_PER_SLOT]; /*!< Num RBs and corresponding symbols allocated */
121         bool         puschPres; /*!< PUSCH presence field */
122         SchPuschInfo *schPuschInfo; /*!< PUSCH info */
123 }SchUlSlotInfo;
124
125 /**
126   * @brief
127   * Cell Control block per cell.
128   */
129 typedef struct schCellCb
130 {
131    uint16_t      cellId;           /*!< Cell ID */
132    Inst          instIdx;          /*!< Index of the scheduler instance */
133    Inst          macInst;          /*!< Index of the MAC instance */
134         uint8_t       numSlots;         /*!< Number of slots in current frame */
135    SlotIndInfo   slotInfo;         /*!< SFN, Slot info being processed*/
136    SchDlSlotInfo *schDlSlotInfo[SCH_NUM_SLOTS]; /*!< SCH resource allocations in DL */
137    SchUlSlotInfo *schUlSlotInfo[SCH_NUM_SLOTS]; /*!< SCH resource allocations in UL */
138         SchCellCfg    cellCfg;                /*!< Cell ocnfiguration */
139         SchRaCb       raCb[SCH_MAX_UE];
140 }SchCellCb;
141
142 /**
143   * @brief
144   * Control block for sch
145   */
146 typedef struct schCb
147 {
148    TskInit       schInit;              /*!< Task Init info */
149    SchGenCb      genCfg;                 /*!< General Config info */
150    SchCellCb     *cells[SCH_MAX_CELLS];  /* Array to store cellCb ptr */  
151 }SchCb;
152
153 /* Declaration for scheduler control blocks */
154 SchCb schCb[SCH_MAX_INST];
155
156 /* function declarations */
157 uint8_t schBroadcastAlloc(SchCellCb *cell, DlBrdcstAlloc *dlBrdcstAlloc,uint16_t slot);
158 uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst inst);
159 uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst);
160 uint8_t schDlRsrcAllocMsg4(Msg4Alloc *msg4Alloc, SchCellCb *cell, uint16_t slot);
161
162
163 /**********************************************************************
164          End of file
165 **********************************************************************/