1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /* This file handles slot indication */
21 #include "common_def.h"
22 #include "phy_stub_utils.h"
25 #include "fapi_vendor_extension.h"
29 uint8_t l1SendUlUserData();
30 uint8_t l1SendStatusPdu();
31 uint16_t l1BuildAndSendSlotIndication();
32 uint16_t l1BuildAndSendStopInd();
35 /*******************************************************************
37 * @brief Generates slot indications
41 * Function : GenerateTicks
43 * Functionality: Generates slot indications
46 * @return ROK - success
49 * ****************************************************************/
53 float milisec = 0.5; /* 0.5ms */
55 float milisec = 1; /* 1ms */
57 struct timespec req = {0};
59 slotIndicationStarted = true;
61 req.tv_nsec = milisec * 1000000L;
63 DU_LOG("\nPHY_STUB : GenerateTicks : Starting to generate slot indications");
65 while(slotIndicationStarted)
67 clock_nanosleep(CLOCK_REALTIME, 0, &req, NULL);
68 /* Send Slot indication indication to lower mac */
69 if(l1BuildAndSendSlotIndication() != ROK)
71 DU_LOG("\nERROR --> PHY_STUB : GenerateTicks(): Failed to build and send Slot Indication");
76 DU_LOG("\nINFO --> PHY_STUB : Slot indication stopped");
78 /* Initialize all global variables */
81 memset(&ueDb, 0, sizeof(UeDb));
83 /* Send Stop indication to MAC */
85 l1BuildAndSendStopInd();
88 /*******************************************************************
90 * @brief Create/cancel thread for generating slot indication
94 * Function : l1HdlSlotIndicaion
96 * Functionality: Create/cancel thread for generating slot indication
99 * @return ROK - success
102 * ****************************************************************/
103 void l1HdlSlotIndicaion(bool stopSlotInd)
106 Buffer *mBuf = NULLP;
110 DU_LOG("\nPHY_STUB: Sending start slot indication event to self");
111 memset(&pst, 0, sizeof(Pst));
112 FILL_PST_PHY_TO_PHY(pst, EVT_PHY_START_SLOT_IND);
113 ODU_GET_MSG_BUF(pst.region, pst.pool, &mBuf);
114 ODU_POST_TASK(&pst, mBuf);
118 slotIndicationStarted = false;
122 /*******************************************************************
124 * @brief Handles Console input
128 * Function : l1ConsoleHandler
130 * Functionality: Handles Console input
133 * @return ROK - success
136 * ****************************************************************/
137 void *l1ConsoleHandler(void *args)
144 /* Send UL user data to DU when user enters 'd' on console */
145 if((ch = getchar()) == 'd')
147 /* Start Pumping data from PHY stub to DU */
148 for(drbIdx = 0; drbIdx < NUM_DRB_TO_PUMP_DATA; drbIdx++) //Number of DRB times the loop will run
150 DU_LOG("\nDEBUG --> PHY STUB: Sending UL User Data[DrbId:%d]",drbIdx);
151 l1SendUlUserData(drbIdx);
154 else if((ch = getchar()) == 'c')
156 /* Send Control PDU from PHY stub to DU */
157 DU_LOG("\nDEBUG --> PHY STUB: Sending Status PDU");
165 /*******************************************************************
167 * @brief Creates thread for handling console input
171 * Function : l1StartConsoleHandler
173 * Functionality: Creates thread for handling console input
176 * @return ROK - success
179 * ****************************************************************/
180 void l1StartConsoleHandler()
186 /* Start thread to receive console input */
187 pthread_attr_init(&attr);
188 pthread_attr_setstacksize(&attr, (size_t)NULLD);
189 pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
190 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
191 retVal = pthread_create(&conThrdId, &attr, l1ConsoleHandler, NULLP);
194 DU_LOG("\nERROR --> PHY STUB : Thread creation failed. Cause %d", retVal);
196 pthread_attr_destroy(&attr);
200 /**********************************************************************
202 **********************************************************************/