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