1 /******************************************************************************
3 * Copyright (c) 2019 Intel.
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.
17 *******************************************************************************/
18 #include "nr5g_fapi_framework.h"
19 #include "nr5g_fapi_fapi2phy_wls.h"
20 #include "nr5g_fapi_phy2mac_thread.h"
21 #include "nr5g_fapi_fapi2mac_api.h"
22 #include "nr5g_fapi_fapi2mac_p5_proc.h"
23 #include "nr5g_fapi_fapi2mac_p7_proc.h"
24 #include "nr5g_fapi_log.h"
25 //------------------------------------------------------------------------------
26 /** @ingroup nr5g_fapi_source_framework_workers_phy2mac_group
36 //------------------------------------------------------------------------------
37 void *nr5g_fapi_phy2mac_thread_func(
42 PMAC2PHY_QUEUE_EL p_msg_list = NULL;
43 p_nr5g_fapi_phy_ctx_t p_phy_ctx = (p_nr5g_fapi_phy_ctx_t) config;
45 NR5G_FAPI_LOG(INFO_LOG, ("[PHY2MAC] Thread %s launched LWP:%ld on "
46 "Core: %d\n", __func__, pthread_self(),
47 p_phy_ctx->phy2mac_worker_core_id));
49 thread = p_phy_ctx->phy2mac_tid = pthread_self();
51 CPU_SET(p_phy_ctx->phy2mac_worker_core_id, &cpuset);
52 pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
54 nr5g_fapi_fapi2mac_init_api_list();
57 while (!p_phy_ctx->process_exit) {
58 p_msg_list = nr5g_fapi_fapi2phy_wls_recv();
60 nr5g_fapi_phy2mac_api_recv_handler(config, p_msg_list);
62 nr5g_fapi_fapi2mac_send_api_list();
67 //------------------------------------------------------------------------------
68 /** @ingroup nr5g_fapi_source_framework_workers_mac2phy_group
78 //------------------------------------------------------------------------------
79 void nr5g_fapi_phy2mac_api_recv_handler(
81 PMAC2PHY_QUEUE_EL p_msg_list)
83 PMAC2PHY_QUEUE_EL p_curr_msg;
84 PL1L2MessageHdr p_msg_header = NULL;
85 uint64_t start_tick = __rdtsc();
87 NR5G_FAPI_LOG(TRACE_LOG, ("[PHY2MAC] %s:", __func__));
89 nr5g_fapi_message_header((p_nr5g_fapi_phy_ctx_t) config);
91 p_curr_msg = (PMAC2PHY_QUEUE_EL) p_msg_list;
93 p_msg_header = (PL1L2MessageHdr) (p_curr_msg + 1);
94 switch (p_msg_header->nMessageType) {
95 /* P5 Vendor Message Processing */
97 case MSG_TYPE_PHY_DL_IQ_SAMPLES:
99 nr5g_fapi_dl_iq_samples_response((p_nr5g_fapi_phy_ctx_t)
100 config, (PADD_REMOVE_BBU_CORES) p_msg_header);
104 case MSG_TYPE_PHY_UL_IQ_SAMPLES:
106 nr5g_fapi_ul_iq_samples_response((p_nr5g_fapi_phy_ctx_t)
107 config, (PADD_REMOVE_BBU_CORES) p_msg_header);
111 case MSG_TYPE_PHY_SHUTDOWN_RESP:
113 nr5g_fapi_shutdown_response((p_nr5g_fapi_phy_ctx_t) config,
114 (PSHUTDOWNRESPONSEStruct) p_msg_header);
118 /* P5 Message Processing */
119 case MSG_TYPE_PHY_CONFIG_RESP:
121 nr5g_fapi_config_response((p_nr5g_fapi_phy_ctx_t) config,
122 (PCONFIGRESPONSEStruct) p_msg_header);
126 case MSG_TYPE_PHY_START_RESP:
128 nr5g_fapi_start_resp((p_nr5g_fapi_phy_ctx_t) config,
129 (PSTARTRESPONSEStruct) p_msg_header);
133 case MSG_TYPE_PHY_STOP_RESP:
135 nr5g_fapi_stop_indication((p_nr5g_fapi_phy_ctx_t) config,
136 (PSTOPRESPONSEStruct) p_msg_header);
140 /* P7 Message Processing */
141 case MSG_TYPE_PHY_RX_ULSCH_IND:
143 nr5g_fapi_rx_data_indication((p_nr5g_fapi_phy_ctx_t) config,
144 (PRXULSCHIndicationStruct) p_msg_header);
148 case MSG_TYPE_PHY_RX_ULSCH_UCI_IND:
154 case MSG_TYPE_PHY_CRC_IND:
156 nr5g_fapi_crc_indication((p_nr5g_fapi_phy_ctx_t) config,
157 (PCRCIndicationStruct) p_msg_header);
161 case MSG_TYPE_PHY_UCI_IND:
163 nr5g_fapi_uci_indication((p_nr5g_fapi_phy_ctx_t) config,
164 (PRXUCIIndicationStruct) p_msg_header);
168 case MSG_TYPE_PHY_RX_RACH_IND:
170 nr5g_fapi_rach_indication((p_nr5g_fapi_phy_ctx_t) config,
171 (PRXRACHIndicationStruct) p_msg_header);
175 case MSG_TYPE_PHY_RX_SRS_IND:
177 nr5g_fapi_srs_indication((p_nr5g_fapi_phy_ctx_t) config,
178 (PRXSRSIndicationStruct) p_msg_header);
182 case MSG_TYPE_PHY_SLOT_IND:
184 nr5g_fapi_slot_indication((p_nr5g_fapi_phy_ctx_t) config,
185 (PSlotIndicationStruct) p_msg_header);
186 nr5g_fapi_statistic_info_set_all();
190 case MSG_TYPE_PHY_ERR_IND:
196 printf("%s: Unknown Message type: %x\n", __func__,
197 p_msg_header->nMessageType);
200 p_curr_msg = p_curr_msg->pNext;
202 tick_total_parse_per_tti_ul += __rdtsc() - start_tick;