Merge "Memory handling fixes"
[o-du/l2.git] / src / 5gnrmac / lwr_mac_ex_ms.c
1 /*******************************************************************************\r
2 ################################################################################\r
3 #   Copyright (c) [2017-2019] [Radisys]                                        #\r
4 #                                                                              #\r
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #\r
6 #   you may not use this file except in compliance with the License.           #\r
7 #   You may obtain a copy of the License at                                    #\r
8 #                                                                              #\r
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #\r
10 #                                                                              #\r
11 #   Unless required by applicable law or agreed to in writing, software        #\r
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #\r
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #\r
14 #   See the License for the specific language governing permissions and        #\r
15 #   limitations under the License.                                             #\r
16 ################################################################################\r
17 *******************************************************************************/\r
18 \r
19 /* This file is the entry point for Lower MAC */\r
20 \r
21 #include "common_def.h"\r
22 #include "mac_utils.h"\r
23 #include "lwr_mac_fsm.h"\r
24 #include "lwr_mac_phy.h"\r
25 #ifdef INTEL_FAPI\r
26 #include "fapi.h"\r
27 #include "fapi_vendor_extension.h"\r
28 #endif\r
29 #ifndef INTEL_WLS_MEM\r
30 #include "lwr_mac_phy_stub_inf.h"\r
31 #endif\r
32 \r
33 /**************************************************************************\r
34  * @brief Task Initiation callback function. \r
35  *\r
36  * @details\r
37  *\r
38  *     Function : lwrMacActvInit \r
39  *    \r
40  *     Functionality:\r
41  *             This function is supplied as one of parameters during Lower MAC's \r
42  *             task registration. SSI will invoke this function once, after\r
43  *             it creates and attaches this TAPA Task to a system task.\r
44  *     \r
45  * @param[in]  Ent entity, the entity ID of this task.     \r
46  * @param[in]  Inst inst, the instance ID of this task.\r
47  * @param[in]  Region region, the region ID registered for memory \r
48  *              usage of this task.\r
49  * @param[in]  Reason reason.\r
50  * @return ROK     - success\r
51  *         RFAILED - failure\r
52  ***************************************************************************/\r
53 uint8_t lwrMacActvInit(Ent entity, Inst inst, Region region, Reason reason)\r
54 {\r
55    return ROK;\r
56 }\r
57 \r
58 /**************************************************************************\r
59  * @brief Task Activation callback function. \r
60  *\r
61  * @details\r
62  *\r
63  *      Function : lwrMacActvTsk \r
64  * \r
65  *      Functionality:\r
66  *           Primitives invoked by Lower MAC's users/providers through\r
67  *           a loosely coupled interface arrive here by means of \r
68  *           SSI's message handling. This API is registered with\r
69  *           SSI during the Task Registration of DU APP.\r
70  *     \r
71  * @param[in]  Pst     *pst, Post structure of the primitive.     \r
72  * @param[in]  Buffer *mBuf, Packed primitive parameters in the\r
73  *  buffer.\r
74  * @return ROK     - success\r
75  *         RFAILED - failure\r
76  *\r
77  ***************************************************************************/\r
78 uint8_t lwrMacActvTsk(Pst *pst, Buffer *mBuf)\r
79 {\r
80    uint8_t ret = ROK;\r
81 \r
82    switch(pst->srcEnt)\r
83    {\r
84       case ENTLWRMAC:\r
85          {\r
86             switch(pst->event)\r
87             {\r
88 #ifdef INTEL_WLS_MEM\r
89                case EVT_START_WLS_RCVR:\r
90                   {\r
91                      ODU_PUT_MSG_BUF(mBuf);\r
92 \r
93                      /* Allocate memory for intial UL transmission */\r
94                      LwrMacEnqueueWlsBlock();\r
95 \r
96                      /* Start thread to receive from L1 */\r
97                      DU_LOG("\nINFO  -->  LWR MAC: Starting WLS receiver thread");\r
98                      LwrMacRecvPhyMsg();\r
99                      break;\r
100                   }\r
101 #endif\r
102                default:\r
103                   {\r
104                      ODU_PUT_MSG_BUF(mBuf);\r
105                      DU_LOG("\nERROR  -->  LWR MAC: Invalid event %d received", pst->event);\r
106                      ret = RFAILED;\r
107                   }\r
108             }\r
109             break;\r
110          }\r
111 \r
112 #ifndef INTEL_WLS_MEM\r
113       case ENTPHYSTUB:\r
114          {\r
115             switch(pst->event)\r
116             {\r
117                case EVT_PHY_STUB_SLOT_IND:\r
118                   {\r
119                      fapi_slot_ind_t *slotIndMsg;\r
120 \r
121                      CMCHKUNPK(oduUnpackPointer, (PTR *)&slotIndMsg, mBuf);\r
122                      ODU_PUT_MSG_BUF(mBuf);\r
123 \r
124                      procPhyMessages(slotIndMsg->header.msg_id, sizeof(fapi_slot_ind_t), (void*)slotIndMsg);\r
125                      MAC_FREE_SHRABL_BUF(pst->region, pst->pool, slotIndMsg, sizeof(fapi_slot_ind_t));\r
126                      break;\r
127                   }\r
128 \r
129                case EVT_PHY_STUB_STOP_IND:\r
130                  {\r
131                     fapi_stop_ind_t *stopIndMsg;\r
132                     CMCHKUNPK(oduUnpackPointer, (PTR *)&stopIndMsg, mBuf);\r
133                     ODU_PUT_MSG_BUF(mBuf);\r
134 \r
135                     procPhyMessages(stopIndMsg->header.msg_id, sizeof(fapi_stop_ind_t), (void*)stopIndMsg);\r
136                     MAC_FREE_SHRABL_BUF(pst->region, pst->pool, stopIndMsg, sizeof(fapi_stop_ind_t));\r
137                     break;\r
138                  }\r
139                default:\r
140                   {\r
141                      DU_LOG("\nERROR  -->  LWR_MAC: Invalid event %d received from PHY STUB", pst->event);\r
142                   }\r
143             }\r
144             break;\r
145          }\r
146 #endif\r
147 \r
148       default:\r
149          {\r
150             ODU_PUT_MSG_BUF(mBuf);\r
151             DU_LOG("\nERROR  -->  LWR MAC: Message from invalid source entity %d", pst->srcEnt);\r
152             ret = RFAILED;\r
153          }\r
154    }\r
155    return ret;\r
156 }\r
157 \r
158 /**********************************************************************\r
159   End of file\r
160  **********************************************************************/\r