[Epic-ID: ODUHIGH-516][Task-ID: ODUHIGH-530] Implementation of Stats Modification...
[o-du/l2.git] / src / 5gnrsch / sch_msg_router.c
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 /************************************************************************
20  
21      Name:     NR-SCH layer
22   
23      Type:     C source file
24   
25      Desc:     C source code SSI Interface Implementation
26   
27      File:     sch_msg_router.c
28   
29 **********************************************************************/
30
31 #include "common_def.h"
32 #include "lrg.h"
33 #include "tfu.h"
34 #include "du_log.h"
35 #include "rgr.h"
36 #include "rg_sch_inf.h"
37 #include "rg_sch.h"
38 #include "mac_sch_interface.h"
39
40 #include "tfu.x"           /* TFU types */
41 #include "lrg.x"           /* layer management typedefs for MAC */
42 #include "rgr.x"           /* layer management typedefs for MAC */
43 #include "rg_sch_inf.x"         /* typedefs for Scheduler */
44 #include "sch.h"
45 #include "sch_tmr.h"
46
47 /**
48  * @brief Task Initiation function. 
49  *
50  * @details
51  *
52  *     Function : schActvInit
53  *     
54  *     This function is supplied as one of parameters during MAC's 
55  *     task registration. MAC will invoke this function once, after
56  *     it creates and attaches this TAPA Task to a system task.
57  *     
58  *  @param[in]  Ent Entity, the entity ID of this task.     
59  *  @param[in]  Inst Inst, the instance ID of this task.
60  *  @param[in]  Region Region, the region ID registered for memory 
61  *              usage of this task.
62  *  @param[in]  Reason Reason.
63  *  @return  int
64  *      -# ROK
65  **/
66 uint8_t schActvInit(Ent entity, Inst instId, Region region, Reason reason)
67 {
68    Inst inst = (instId  - SCH_INST_START);
69
70    /* Initialize the MAC TskInit structure to zero */
71    memset ((uint8_t *)&schCb[inst], 0, sizeof(schCb));
72
73    /* Initialize the MAC TskInit with received values */
74    schCb[inst].schInit.ent = entity;
75    schCb[inst].schInit.inst = inst;
76    schCb[inst].schInit.region = region;
77    schCb[inst].schInit.pool = 0;
78    schCb[inst].schInit.reason = reason;
79    schCb[inst].schInit.cfgDone = FALSE;
80    schCb[inst].schInit.acnt = FALSE;
81    schCb[inst].schInit.usta = FALSE;
82    schCb[inst].schInit.trc = FALSE;
83    schCb[inst].schInit.procId = ODU_GET_PROCID();
84
85    return ROK;
86 } /* schActvInit */
87
88 /**
89  * @brief Task Activation callback function.
90  *
91  * @details
92  *
93  *     Function : schActvTsk
94  *
95  *     Primitives invoked by SCH's users/providers through
96  *     a loosely coupled interface arrive here by means of
97  *     SSI's message handling. This API is registered with
98  *     SSI during the Task Registration of SCH.
99  *
100  *  @param[in]  Pst     *pst, Post structure of the primitive.
101  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
102  *  @param[in]  Reason reason.
103  *  @return  uint8_t
104  *      -# ROK
105  **/
106 uint8_t schActvTsk(Pst *pst, Buffer *mBuf)
107 {
108    SchMessageRouter(pst, (void *)mBuf);
109
110    ODU_EXIT_TASK();
111    return ROK;
112 }
113
114 #ifdef CALL_FLOW_DEBUG_LOG
115 /**
116 * @brief Function prints src, dest, msg infor about all the msgs that received.
117 *
118 * @details
119 *
120 *     Function : callFlowSchMsgRouter 
121 *
122 *     Function prints src, dest, msg infor about all the msgs that received
123 *
124 *  @param[in]  Pst     *pst, Post structure of the primitive.
125 *
126 *  @return  void
127 **/
128
129 void callFlowSchMsgRouter(Pst *pst)
130 {
131    char sourceTask[50];
132    char destTask[50]="ENTSCH";
133    char message[100];
134
135    strcpy(sourceTask,"ENTMAC");
136    switch(pst->event)
137    {
138       case EVENT_SCH_GEN_CFG:
139          {
140             strcpy(message,"EVENT_SCH_GEN_CFG");
141             break;
142          }   
143       case EVENT_SLICE_CFG_REQ_TO_SCH:
144          {      
145             strcpy(message,"EVENT_SLICE_CFG_REQ_TO_SCH");
146             break;
147          }      
148       case EVENT_SLICE_RECFG_REQ_TO_SCH:
149          {      
150             strcpy(message,"EVENT_SLICE_RECFG_REQ_TO_SCH");
151             break;
152          }   
153       case EVENT_SCH_CELL_CFG:
154          {
155             strcpy(message,"EVENT_SCH_CELL_CFG");
156             break;
157          }   
158       case EVENT_SLOT_IND_TO_SCH:
159          {
160             strcpy(message,"EVENT_SLOT_IND_TO_SCH");
161             break;
162          }   
163       case EVENT_ADD_UE_CONFIG_REQ_TO_SCH:
164          {   
165             strcpy(message,"EVENT_ADD_UE_CONFIG_REQ_TO_SCH");
166             break;
167          }   
168       case EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH:
169          {   
170             strcpy(message,"EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH");
171             break;
172          }
173       case EVENT_UL_CQI_TO_SCH:
174          {
175             strcpy(message,"EVENT_UL_CQI_TO_SCH");
176             break;
177          }
178       case EVENT_DL_CQI_TO_SCH:
179          {
180             strcpy(message,"EVENT_DL_CQI_TO_SCH");
181             break;
182          }
183       case EVENT_PHR_IND_TO_SCH
184          {
185             strcpy(message,"EVENT_PHR_IND_TO_SCH");
186          }
187       case EVENT_RACH_IND_TO_SCH:
188          {
189             strcpy(message,"EVENT_RACH_IND_TO_SCH");
190             break;
191          }
192       case EVENT_CRC_IND_TO_SCH:
193          {
194             strcpy(message,"EVENT_CRC_IND_TO_SCH");
195             break;
196          }
197       case EVENT_DL_RLC_BO_INFO_TO_SCH:
198          {
199             strcpy(message,"EVENT_DL_RLC_BO_INFO_TO_SCH");
200             break;
201          }
202       case EVENT_SHORT_BSR:
203          {
204             strcpy(message,"EVENT_SHORT_BSR");
205             break;
206          }
207       case EVENT_LONG_BSR:
208          {
209             strcpy(message,"EVENT_LONG_BSR");
210             break;
211          }
212       case EVENT_UCI_IND_TO_SCH:
213          {
214             strcpy(message,"EVENT_UCI_IND_TO_SCH");
215             break;
216          }
217       case EVENT_UE_DELETE_REQ_TO_SCH:
218          {
219             strcpy(message,"EVENT_UE_DELETE_REQ_TO_SCH");
220             break;
221          }
222       case EVENT_CELL_DELETE_REQ_TO_SCH:
223          {
224             strcpy(message,"EVENT_CELL_DELETE_REQ_TO_SCH");
225             break;
226          }
227       case EVENT_RACH_RESOURCE_REQUEST_TO_SCH:
228          {
229             strcpy(message,"EVENT_RACH_RESOURCE_REQUEST_TO_SCH");
230             break;
231          }
232       case EVENT_RACH_RESOURCE_RELEASE_TO_SCH:
233          {
234             strcpy(message,"EVENT_RACH_RESOURCE_RELEASE_TO_SCH");
235             break;
236          }
237       case EVENT_PAGING_IND_TO_SCH:
238          {
239             strcpy(message,"EVENT_PAGING_IND_TO_SCH");
240             break;
241          }
242       case EVENT_DL_HARQ_IND_TO_SCH:
243          {
244             strcpy(message,"EVENT_DL_HARQ_IND_TO_SCH");
245             break;
246          }
247       case EVENT_STATISTICS_REQ_TO_SCH:
248          {
249             strcpy(message,"EVENT_STATISTICS_REQ_TO_SCH");
250             break;
251          }
252       case EVENT_STATISTICS_DELETE_REQ_TO_SCH:
253          {
254             strcpy(message,"EVENT_STATISTICS_DELETE_REQ_TO_SCH");
255             break;
256          }
257       case EVENT_STATISTICS_MODIFY_REQ_TO_SCH:
258          {
259             strcpy(message,"EVENT_STATISTICS_MODIFY_REQ_TO_SCH");
260             break;
261          }
262       default:
263          strcpy(message,"Invalid Event");
264          break;
265    }
266    DU_LOG("\nCall Flow: %s -> %s : %s\n", sourceTask, destTask, message);
267 }
268 #endif
269
270 uint8_t SchMessageRouter(Pst *pst, void *msg)
271 {
272 #ifdef CALL_FLOW_DEBUG_LOG
273    callFlowSchMsgRouter(pst);
274 #endif
275
276    switch(pst->event)
277    {
278       case EVENT_SCH_GEN_CFG:
279       {
280             SchProcGenCfgReq(pst, (RgMngmt *)msg);
281          break;
282       }
283       case EVENT_SLICE_CFG_REQ_TO_SCH:
284       {    
285          SchProcSliceCfgReq(pst, (SchSliceCfgReq *)msg);
286          break;
287       }    
288       case EVENT_SLICE_RECFG_REQ_TO_SCH:
289       {    
290          SchProcSliceRecfgReq(pst, (SchSliceRecfgReq *)msg);
291          break;
292       }
293       case EVENT_SCH_CELL_CFG:
294       {
295          SchProcCellCfgReq(pst, (SchCellCfg *)msg);
296          break;
297       }
298       case EVENT_SLOT_IND_TO_SCH:
299       {
300          SchProcSlotInd(pst, (SlotTimingInfo *)msg);
301          break;
302       }
303       case EVENT_ADD_UE_CONFIG_REQ_TO_SCH:
304       {
305          SchAddUeConfigReq(pst, (SchUeCfgReq *)msg);
306          break;
307       }
308       case EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH:
309       {
310          SchModUeConfigReq(pst, (SchUeRecfgReq *)msg);
311          break;
312       }
313       case EVENT_UL_CQI_TO_SCH:
314       {
315          SchProcUlCqiInd(pst, (SchUlCqiInd *)msg);
316          break;
317       }
318       case EVENT_DL_CQI_TO_SCH:
319       {
320          SchProcDlCqiInd(pst, (SchDlCqiInd *)msg);
321          break;
322       }
323       case EVENT_PHR_IND_TO_SCH:
324       {
325          SchProcPhrInd(pst, (SchPwrHeadroomInd *)msg);
326          break;
327       }
328       case EVENT_RACH_IND_TO_SCH:
329       {
330          SchProcRachInd(pst, (RachIndInfo *)msg);
331          break;
332       }
333       case EVENT_CRC_IND_TO_SCH:
334       {
335          SchProcCrcInd(pst, (CrcIndInfo *)msg);
336          break;
337       }
338       case EVENT_DL_RLC_BO_INFO_TO_SCH:
339       {
340          SchProcDlRlcBoInfo(pst, (DlRlcBoInfo *)msg);
341          break;
342       }
343       case EVENT_SHORT_BSR:
344       case EVENT_LONG_BSR:
345       {
346          SchProcBsr(pst, (UlBufferStatusRptInd *)msg);
347          break;
348       }
349       case EVENT_UCI_IND_TO_SCH:
350       {
351          SchProcSrUciInd(pst, (SrUciIndInfo *)msg);
352          break;
353       }
354       case EVENT_UE_DELETE_REQ_TO_SCH:
355       {
356          SchProcUeDeleteReq(pst, (SchUeDelete *)msg);
357          break;
358       }
359       case EVENT_CELL_DELETE_REQ_TO_SCH:
360       {
361          SchProcCellDeleteReq(pst, (SchCellDeleteReq *)msg);
362          break;
363       }
364       case EVENT_RACH_RESOURCE_REQUEST_TO_SCH:
365       {
366          SchProcRachRsrcReq(pst, (SchRachRsrcReq *)msg);
367          break;
368       }
369       case EVENT_RACH_RESOURCE_RELEASE_TO_SCH:
370       {
371          SchProcRachRsrcRel(pst, (SchRachRsrcRel *)msg);
372          break;
373       }
374       case EVENT_PAGING_IND_TO_SCH:
375       {
376          SchProcPagingInd(pst, (SchPageInd *)msg);
377          break;
378       }
379       case EVENT_DL_HARQ_IND_TO_SCH:
380       {
381          SchProcDlHarqInd(pst, (DlHarqInd *)msg);
382          break;
383       }
384       case EVENT_STATISTICS_REQ_TO_SCH:
385       {
386          SchProcStatsReq(pst, (SchStatsReq *)msg);
387          break;
388       }
389       case EVENT_STATISTICS_DELETE_REQ_TO_SCH:
390       {
391          SchProcStatsDeleteReq(pst, (SchStatsDeleteReq *)msg);
392          break;
393       }
394       case EVENT_STATISTICS_MODIFY_REQ_TO_SCH:
395       {
396          SchProcStatsModificationReq(pst, (SchStatsModificationReq *)msg);
397          break;
398       }
399       default:
400       {
401          DU_LOG("\nERROR  -->  SCH : SchMessageRouter(): Invalid event [%d] received", pst->event);
402          return RFAILED;
403       }
404    }
405    return ROK;
406 }
407
408 \f
409 /**********************************************************************
410  
411          End of file
412 **********************************************************************/