abf31e35fd1f03baf0e467047767afbb2f62973c
[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 function prints src, dest, msg info about all the msgs received \r
60 *\r
61 * @details\r
62 *\r
63 *     Function : callFlowlwrMacActvTsk \r
64 *\r
65 *     Functionality:\r
66 *          function prints src, dest, msg info about all the msgs received\r
67 *\r
68 * @param[in]  Pst *pst\r
69 *\r
70 * @return void \r
71 ***************************************************************************/\r
72 \r
73 void callFlowlwrMacActvTsk(Pst *pst)\r
74 {\r
75    char sourceTask[50];\r
76    char destTask[50]="ENTLWRMAC";\r
77    char message[100];\r
78 \r
79    switch(pst->srcEnt)\r
80    {\r
81       case ENTLWRMAC:\r
82          {\r
83             strcpy(sourceTask,"ENTLWRMAC");\r
84             switch(pst->event)\r
85             {\r
86 #ifdef INTEL_WLS_MEM\r
87                case EVT_START_WLS_RCVR:\r
88                   {\r
89                      strcpy(message,"EVT_START_WLS_RCVR");\r
90                      break;\r
91                   }\r
92 #endif\r
93                default:\r
94                   {\r
95                      strcpy(message,"Invalid Event");\r
96                      break;\r
97                   }\r
98             }\r
99             break;\r
100          }\r
101 \r
102 #ifndef INTEL_WLS_MEM\r
103       case ENTPHYSTUB:\r
104          {\r
105             strcpy(sourceTask,"PHY");\r
106             switch(pst->event)\r
107             {\r
108                case EVT_PHY_STUB_SLOT_IND:\r
109                   {\r
110                      strcpy(message,"EVT_PHY_STUB_SLOT_IND");\r
111                      break;\r
112                   }\r
113 \r
114                case EVT_PHY_STUB_STOP_IND:\r
115                  {\r
116                     strcpy(message,"EVT_PHY_STUB_STOP_IND");\r
117                     break;\r
118                  }\r
119                default:\r
120                   {\r
121                      strcpy(message,"Invalid Event");\r
122                      break;\r
123                   }\r
124             }\r
125             break;\r
126          }\r
127 #endif\r
128 \r
129       default:\r
130          {\r
131             strcpy(sourceTask,"Invalid Source Entity Id");\r
132          }\r
133    }\r
134    DU_LOG("\nCall Flow: %s -> %s : %s\n", sourceTask, destTask, message);\r
135 }\r
136 /**************************************************************************\r
137  * @brief Task Activation callback function. \r
138  *\r
139  * @details\r
140  *\r
141  *      Function : lwrMacActvTsk \r
142  * \r
143  *      Functionality:\r
144  *           Primitives invoked by Lower MAC's users/providers through\r
145  *           a loosely coupled interface arrive here by means of \r
146  *           SSI's message handling. This API is registered with\r
147  *           SSI during the Task Registration of DU APP.\r
148  *     \r
149  * @param[in]  Pst     *pst, Post structure of the primitive.     \r
150  * @param[in]  Buffer *mBuf, Packed primitive parameters in the\r
151  *  buffer.\r
152  * @return ROK     - success\r
153  *         RFAILED - failure\r
154  *\r
155  ***************************************************************************/\r
156 uint8_t lwrMacActvTsk(Pst *pst, Buffer *mBuf)\r
157 {\r
158    uint8_t ret = ROK;\r
159 \r
160 #ifdef CALL_FLOW_DEBUG_LOG\r
161    callFlowlwrMacActvTsk(pst);\r
162 #endif\r
163    \r
164    switch(pst->srcEnt)\r
165    {\r
166       case ENTLWRMAC:\r
167          {\r
168             switch(pst->event)\r
169             {\r
170 #ifdef INTEL_WLS_MEM\r
171                case EVT_START_WLS_RCVR:\r
172                   {\r
173                      ODU_PUT_MSG_BUF(mBuf);\r
174 \r
175                      /* Allocate memory for intial UL transmission */\r
176                      LwrMacEnqueueWlsBlock();\r
177 \r
178                      /* Start thread to receive from L1 */\r
179                      DU_LOG("\nINFO  -->  LWR MAC: Starting WLS receiver thread");\r
180                      LwrMacRecvPhyMsg();\r
181                      break;\r
182                   }\r
183 #endif\r
184                default:\r
185                   {\r
186                      ODU_PUT_MSG_BUF(mBuf);\r
187                      DU_LOG("\nERROR  -->  LWR MAC: Invalid event %d received", pst->event);\r
188                      ret = RFAILED;\r
189                   }\r
190             }\r
191             break;\r
192          }\r
193 \r
194 #ifndef INTEL_WLS_MEM\r
195       case ENTPHYSTUB:\r
196          {\r
197             switch(pst->event)\r
198             {\r
199                case EVT_PHY_STUB_SLOT_IND:\r
200                   {\r
201                      fapi_slot_ind_t *slotIndMsg;\r
202 \r
203                      CMCHKUNPK(oduUnpackPointer, (PTR *)&slotIndMsg, mBuf);\r
204                      ODU_PUT_MSG_BUF(mBuf);\r
205 \r
206                      procPhyMessages(slotIndMsg->header.msg_id, sizeof(fapi_slot_ind_t), (void*)slotIndMsg);\r
207                      MAC_FREE_SHRABL_BUF(pst->region, pst->pool, slotIndMsg, sizeof(fapi_slot_ind_t));\r
208                      break;\r
209                   }\r
210 \r
211                case EVT_PHY_STUB_STOP_IND:\r
212                  {\r
213                     fapi_stop_ind_t *stopIndMsg;\r
214                     CMCHKUNPK(oduUnpackPointer, (PTR *)&stopIndMsg, mBuf);\r
215                     ODU_PUT_MSG_BUF(mBuf);\r
216 \r
217                     procPhyMessages(stopIndMsg->header.msg_id, sizeof(fapi_stop_ind_t), (void*)stopIndMsg);\r
218                     MAC_FREE_SHRABL_BUF(pst->region, pst->pool, stopIndMsg, sizeof(fapi_stop_ind_t));\r
219                     break;\r
220                  }\r
221                default:\r
222                   {\r
223                      DU_LOG("\nERROR  -->  LWR_MAC: Invalid event %d received from PHY STUB", pst->event);\r
224                   }\r
225             }\r
226             break;\r
227          }\r
228 #endif\r
229 \r
230       default:\r
231          {\r
232             ODU_PUT_MSG_BUF(mBuf);\r
233             DU_LOG("\nERROR  -->  LWR MAC: Message from invalid source entity %d", pst->srcEnt);\r
234             ret = RFAILED;\r
235          }\r
236    }\r
237    return ret;\r
238 }\r
239 \r
240 /**********************************************************************\r
241   End of file\r
242  **********************************************************************/\r