* INTC Contribution to the O-RAN F Release for O-DU Low
[o-du/phy.git] / fapi_5g / source / framework / workers / nr5g_fapi_urllc_mac2phy_thread.c
1 /******************************************************************************
2 *
3 *   Copyright (c) 2022 Intel.
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 #include "nr5g_fapi_std.h"
19 #include "nr5g_fapi_framework.h"
20 #include "nr5g_fapi_phy2mac_thread.h"
21 #include "nr5g_fapi_mac2phy_thread.h"
22 #include "nr5g_fapi_fapi2mac_api.h"
23 #include "nr5g_fapi_fapi2phy_api.h"
24
25 void *nr5g_fapi_urllc_mac2phy_thread_func(
26     void *config)
27 {
28     p_nr5g_fapi_phy_ctx_t p_phy_ctx = (p_nr5g_fapi_phy_ctx_t) config;
29     uint64_t start_tick;
30
31     NR5G_FAPI_LOG(INFO_LOG, ("[URLLC_MAC2PHY] Thread %s launched LWP:%ld on "
32             "Core: %d\n", __func__, pthread_self(),
33             p_phy_ctx->urllc_mac2phy_worker_core_id));
34
35     nr5g_fapi_init_thread(p_phy_ctx->urllc_mac2phy_worker_core_id);
36
37     while (!p_phy_ctx->process_exit) {
38         sem_wait(&p_phy_ctx->urllc_mac2phy_params.urllc_sem_process);
39         pthread_mutex_lock(&p_phy_ctx->urllc_mac2phy_params.lock);
40         if (p_phy_ctx->urllc_mac2phy_params.p_urllc_list_elem)
41         {
42             nr5g_fapi_mac2phy_api_recv_handler(true, config, 
43                     (p_fapi_api_queue_elem_t) p_phy_ctx->urllc_mac2phy_params.
44                     p_urllc_list_elem);
45             start_tick = __rdtsc();
46             NR5G_FAPI_LOG(TRACE_LOG, ("[MAC2PHY] Send to PHY urllc.."));
47             nr5g_fapi_fapi2phy_send_api_list(true);
48             tick_total_wls_send_per_tti_dl += __rdtsc() - start_tick;
49
50             p_phy_ctx->urllc_mac2phy_params.p_urllc_list_elem = NULL;
51         }
52         pthread_mutex_unlock(&p_phy_ctx->urllc_mac2phy_params.lock);
53         sem_post(&p_phy_ctx->urllc_mac2phy_params.urllc_sem_done);
54     }
55  
56     pthread_exit(NULL);
57 }