MAC/SCH Ue Delete Request and Response [JIRA ID - ODUHIGH-318]
[o-du/l2.git] / src / 5gnrmac / rg_ex_ms.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:     LTE-MAC layer
22   
23      Type:     C source file
24   
25      Desc:     C source code SSI Interface Implementation
26   
27      File:     rg_ex_ms.c 
28   
29 **********************************************************************/
30
31 /** @file rg_ex_ms.c
32 @brief This file contains the implementation of callback functions 
33 registered with SSI during the LTE MAC Task initialization.
34 */
35 /* header include files -- defines (.h) */
36 #include "common_def.h"
37 #include "rgu.h"           /* RGU defines */
38 #include "tfu.h"           /* RGU defines */
39 #include "lrg.h"           /* layer management defines for LTE-MAC */
40 #include "rgr.h"           /* layer management defines for LTE-MAC */
41 #include "crg.h"           /* CRG interface includes */
42 #include "rg_sch_inf.h"    /* SCH interface includes */
43 #include "rg_prg.h"        /* PRG interface includes */
44 #include "rg_env.h"        /* customisable defines and macros for LTE-MAC */
45 #include "rg.h"            /* defines and macros for MAC */
46 #include "rgr.h"            /* defines and macros for SCH */
47
48
49 /* header/extern include files (.x) */
50 #include "rgu.x"           /* RGU types */
51 #include "tfu.x"           /* RGU types */
52 #include "lrg.x"           /* layer management typedefs for MAC */
53 #include "rgr.x"           /* layer management typedefs for MAC */
54 #include "crg.x"           /* CRG interface typedes */
55 #include "rg_sch_inf.x"    /* SCH interface typedefs */
56 #include "rg_prg.x"        /*PRG interface includes*/
57 #include "du_app_mac_inf.h"
58 #include "rg.x"            /* typedefs for MAC */
59 #include "rlc_mac_inf.h"
60 #include "lwr_mac_upr_inf.h"
61
62 /**
63  * @brief Task Activation callback function Entity SM. 
64  *
65  * @details
66  *
67  *     Function : rgHdlSMEvents
68  *     
69  *     Process Messages received from Entity SM
70  *     
71  *  @param[in]  Pst     *pst, Post structure of the primitive.     
72  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
73  *  @param[in]  Reason reason.
74  *  @return  void
75  **/
76 static inline void rgHdlSMEvents
77 (
78 Pst     *pst,                       /* post structure       */
79 Buffer  *mBuf                       /* message buffer       */
80 )
81 {
82    switch(pst->event)
83    {
84 #ifdef LCRGMILRG
85       case EVTLRGCFGREQ:
86          /* Process a config. request */
87          cmUnpkLrgCfgReq(RgMiLrgCfgReq, pst, mBuf);
88          break;
89       case EVTMACSCHGENCFGREQ:
90          /* Process a config. request */
91          cmUnpkLrgSchCfgReq(MacSchGenCfgReq, pst, mBuf);
92          break;
93       case EVTLRGCNTRLREQ:
94          /* Process a control request */
95          cmUnpkLrgCntrlReq(RgMiLrgCntrlReq, pst, mBuf);
96          break;
97       case EVTLRGSSTAREQ:
98          /* Process a status request  */
99          cmUnpkLrgStaReq(RgMiLrgStaReq, pst, mBuf);
100          break;
101       case EVTLRGSTSREQ:
102          /* Process a statistics request */
103          cmUnpkLrgStsReq(RgMiLrgStsReq, pst, mBuf);
104          break;
105 #endif /* LCRGMILRG */
106       case EVENT_MAC_CELL_CONFIG_REQ:
107          /* Process MAC cell config */
108          unpackDuMacCellCfg(MacProcCellCfgReq, pst, mBuf);
109          break;
110       case EVENT_MAC_CELL_START:
111          /* Process MAC cell start request */
112          unpackMacCellStart(MacProcCellStart, pst, mBuf);
113          break;
114       case EVENT_MAC_CELL_STOP:
115          /* Process MAC cell stop request */
116          unpackMacCellStop(MacProcCellStop, pst, mBuf);
117          break;
118       case EVENT_MAC_DL_CCCH_IND:
119          /* Process DL CCCH Ind */
120          unpackMacDlCcchInd(MacProcDlCcchInd, pst, mBuf);
121          break;
122       case EVENT_MAC_UE_CREATE_REQ:
123          /* Process Ue Create Request */
124          unpackMacUeCreateReq(MacProcUeCreateReq, pst, mBuf);
125          break;
126       case EVENT_MAC_UE_RECONFIG_REQ:
127          /* Process Ue Reconfig Request */
128          unpackMacUeReconfigReq(MacProcUeReconfigReq, pst, mBuf);
129          break;
130     case EVENT_MAC_UE_DELETE_REQ:
131     {
132        unpackMacUeDeleteReq(MacProcUeDeleteReq, pst, mBuf);
133        break;
134     }
135     default:
136          RG_FREE_MSG(mBuf);
137          break;
138    }
139 }
140
141
142 /**
143  * @brief Task Activation callback function Entity NH. 
144  *
145  * @details
146  *
147  *     Function : rgHdlNHEvents
148  *     
149  *     Process Messages received from Entity NH
150  *     
151  *  @param[in]  Pst     *pst, Post structure of the primitive.     
152  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
153  *  @param[in]  Reason reason.
154  *  @return  void
155  **/
156 static inline void rgHdlNHEvents
157 (
158 Pst     *pst,                       /* post structure       */
159 Buffer  *mBuf                       /* message buffer       */
160 )
161 {
162    switch(pst->event)
163    {
164 #ifdef LCRGUICRG
165       case EVTCRGBNDREQ:
166          cmUnpkCrgBndReq(RgUiCrgBndReq, pst, mBuf);
167          break;
168       case EVTCRGUBNDREQ:
169          cmUnpkCrgUbndReq(RgUiCrgUbndReq, pst, mBuf);
170          break;
171       case EVTCRGCFGREQ:
172          cmUnpkCrgCfgReq(RgUiCrgCfgReq, pst, mBuf);
173          break;
174 #endif            
175       default:
176          RG_FREE_MSG(mBuf);
177          break;
178    }
179 }
180
181 /**
182  * @brief Task Activation callback function Entity KW. 
183  *
184  * @details
185  *
186  *     Function : rgHdlKWEvents
187  *     
188  *     Process Messages received from Entity KW
189  *     
190  *  @param[in]  Pst     *pst, Post structure of the primitive.     
191  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
192  *  @param[in]  Reason reason.
193  *  @return  void
194  **/
195 static inline void rgHdlKWEvents
196 (
197 Pst     *pst,                       /* post structure       */
198 Buffer  *mBuf                       /* message buffer       */
199 )
200 {
201    switch(pst->event)
202    {
203 #ifdef LCRGUIRGU
204       case EVTRGUBNDREQ:
205          cmUnpkRguBndReq(RgUiRguBndReq, pst, mBuf);
206          break;
207       case EVTRGUUBNDREQ:
208          cmUnpkRguUbndReq(RgUiRguUbndReq, pst, mBuf);
209          break;
210       case EVENT_DL_DATA_TO_MAC:
211          unpackRlcDlData(MacProcRlcDlData, pst, mBuf);
212          break;
213       case EVENT_BO_STATUS_TO_MAC:
214          unpackRlcBoStatus(MacProcRlcBoStatus, pst, mBuf);
215          break;
216 #ifdef LTE_L2_MEAS
217
218       case EVTRGUL2MULTHRPMEASREQ:
219          cmUnpkRguL2MUlThrpMeasReq(RgUiRguL2MUlThrpMeasReq, pst,mBuf);
220          break;
221
222 #endif
223 #endif            
224       default:
225          RG_FREE_MSG(mBuf);
226          break;
227    }
228 }
229
230 /**
231  * @brief Task Activation callback function Entity TF. 
232  *
233  * @details
234  *
235  *     Function : rgHdlTFEvents
236  *     
237  *     Process Messages received from Entity TF
238  *     
239  *  @param[in]  Pst     *pst, Post structure of the primitive.     
240  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
241  *  @param[in]  Reason reason.
242  *  @return  void
243  **/
244 static inline void rgHdlTFEvents
245 (
246 Pst     *pst,                       /* post structure       */
247 Buffer  *mBuf                       /* message buffer       */
248 )
249 {
250    switch(pst->event)
251    {
252       case EVENT_SLOT_IND_TO_MAC:
253          unpackSlotInd(fapiMacSlotInd, pst, mBuf);
254          break;
255       case EVENT_STOP_IND_TO_MAC:
256          unpackStopInd(fapiMacStopInd, pst, mBuf);
257          break;
258       case EVENT_RACH_IND_TO_MAC:
259          unpackRachInd(fapiMacRachInd, pst, mBuf);
260          break;
261       case EVENT_CRC_IND_TO_MAC:
262          unpackCrcInd(fapiMacCrcInd, pst, mBuf);
263          break;
264       case EVENT_RX_DATA_IND_TO_MAC:
265          unpackRxDataInd(fapiMacRxDataInd, pst, mBuf);
266          break;
267       case EVENT_UCI_IND_TO_MAC:
268          unpackUciInd(FapiMacUciInd, pst, mBuf);
269          break;
270       default:
271          RG_FREE_MSG(mBuf);
272          break;
273    }
274 }
275
276
277 /**
278  * @brief Task Activation callback function Entity RG SCH. 
279  *
280  * @details
281  *
282  *     Function : rgHdlRGEvents
283  *     
284  *     Process Messages received from Entity RG SCH
285  *     
286  *  @param[in]  Pst     *pst, Post structure of the primitive.     
287  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
288  *  @param[in]  Reason reason.
289  *  @return  void
290  **/
291 static inline void rgHdlRGEvents
292 (
293 Pst     *pst,                       /* post structure       */
294 Buffer  *mBuf                       /* message buffer       */
295 )
296 {
297    switch(pst->event)
298    {
299 #ifdef LCRG
300       case EVTINFCELLREGREQ:
301          cmUnpkSchMacCellRegReq(RgSchMacCellRegReq, pst, mBuf);
302          break;
303       case EVTINFSFALLOCREQ:
304          cmUnpkSchMacSfAllocReq(RgSchMacSfAllocReq, pst, mBuf);
305          break;
306       case EVTINFRLSHQREQ:
307          cmUnpkSchMacRlsHqReq(RgSchMacRlsHqReq, pst, mBuf);
308          break;
309       case EVTINFHQENTRESET:
310          cmUnpkSchMacRstHqEntReq(RgSchMacRstHqEntReq, pst, mBuf);
311          break;
312       case EVTINFRLSRNTIREQ:
313          cmUnpkSchMacRlsRntiReq(RgSchMacRlsRntiReq, pst, mBuf);
314          break;
315 #ifdef LTEMAC_SPS
316       case EVTINFSPSLCREG:
317          cmUnpkSchMacSpsLcRegReq(RgSchMacSpsLcRegReq, pst, mBuf);
318          break;
319       case EVTINFSPSLCDEREG:
320          cmUnpkSchMacSpsLcDeregReq(RgSchMacSpsLcDeregReq, pst, mBuf);
321          break;
322       case EVTINFSPSRESET:
323          cmUnpkSchMacUlSpsResetReq(RgSchMacUlSpsResetReq, pst, mBuf);
324          break;
325 #endif /* LTEMAC_SPS */
326 #ifdef LTE_L2_MEAS
327       case EVTINFL2MEASREQ:
328          cmUnpkSchMacL2MeasReq(RgSchMacL2MeasReq, pst, mBuf);
329          break;
330       case EVTINFL2MEASSENDREQ :
331          cmUnpkSchMacL2MeasSendReq(RgSchMacL2MeasSendReq, pst , mBuf);
332          break;
333       case EVTINFL2MEASSTOPREQ:
334          cmUnpkSchMacL2MeasStopReq(RgSchMacL2MeasStopReq, pst , mBuf);
335          break;
336 #endif/* LTE_L2_MEAS */
337       case EVTINFLCGREG:
338          cmUnpkSchMacLcgRegReq(RgSchMacLcgRegReq, pst, mBuf);
339          break;
340 #endif            
341 #if defined(LTE_ADV) && defined(LCPRG)
342       case EVTPRGUESCELLCFGREQ:
343       {
344          cmUnpkPrgPMacSMacUeSCellCfgReq(RgPrgPMacSMacUeSCellCfgReq, pst, mBuf);
345       }
346       break;
347       case EVTPRGUESCELLCFGCFM:
348       case EVTPRGUESCELLLCHMODCFM:
349       case EVTPRGUESCELLLCHDELCFMDEL:
350       case EVTPRGUESCELLLCHADDCFM:
351       {
352          cmUnpkPrgSMacPMacCfgCfm(RgPrgSMacPMacCfgCfm, pst, mBuf);
353       }
354       break;
355       case EVTPRGUESCELLDELREQ:
356       {
357          cmUnpkPrgPMacSMacUeSCellDelReq(RgPrgPMacSMacUeSCellDelReq, pst, mBuf);
358       }
359       break;
360       case EVTPRGUESCELLLCHMODREQ:
361       {
362          cmUnpkPrgPMacSMacUeSCellLchModReq(RgPrgPMacSMacUeSCellLchModReq, pst,
363                                            mBuf);
364       }
365       break;
366       case EVTPRGUESCELLLCHDELREQ:
367       {
368          cmUnpkPrgPMacSMacUeSCellLchDelReq(RgPrgPMacSMacUeSCellLchDelReq, pst,
369                                            mBuf);
370       }
371       break;
372       case EVTPRGUESCELLLCHADDREQ:
373       {
374          cmUnpkPrgPMacSMacUeSCellLchAddReq(RgPrgPMacSMacUeSCellLchAddReq, pst,
375                                            mBuf);
376       }
377       break;
378
379 #endif
380       default:
381       {
382          RG_FREE_MSG(mBuf);
383          break;
384       }
385
386    }
387 }
388
389
390 \f
391 /**
392  * @brief Task Activation callback function. 
393  *
394  * @details
395  *
396  *     Function : rgActvTsk
397  *     
398  *     Primitives invoked by MAC's users/providers through
399  *     a loosely coupled interface arrive here by means of 
400  *     SSI's message handling. This API is registered with
401  *     SSI during the Task Registration of MAC.
402  *     
403  *  @param[in]  Pst     *pst, Post structure of the primitive.     
404  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
405  *  @param[in]  Reason reason.
406  *  @return  S16
407  *      -# ROK
408  **/
409 S16 rgActvTsk
410 (
411 Pst     *pst,                       /* post structure       */
412 Buffer  *mBuf                       /* message buffer       */
413 )
414 {
415    switch(pst->srcEnt)
416    {
417       /* The originator of this message is the stack manager,
418        * unpack and go to the respective primitive processing function */
419       case ENTDUAPP:
420           rgHdlSMEvents(pst, mBuf);
421            break;
422       case ENTNH:
423           rgHdlNHEvents(pst, mBuf);
424           break;
425       case ENTRLC:
426           rgHdlKWEvents(pst, mBuf);
427           break;
428       case ENTLWRMAC:
429           rgHdlTFEvents(pst, mBuf);
430           break;
431       case ENTMAC: /* When scheduler instance sends msg to MAC */
432           rgHdlRGEvents(pst, mBuf);
433           break;
434        default:
435           RG_FREE_MSG(mBuf);
436           break;
437    }
438    ODU_EXIT_TASK();
439    return ROK;
440 }/* end of rgActvTsk */
441
442 \f
443 /**********************************************************************
444  
445          End of file
446 **********************************************************************/