1 /******************************************************************************
3 * Copyright (c) 2021 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 *******************************************************************************/
20 * @file This file contains implementation of all the functions used
21 * to send APIs from FAPI to PHY
25 #include "nr5g_mac_phy_api.h"
27 #include "nr5g_fapi_internal.h"
28 #include "nr5g_fapi_wls.h"
29 #include "nr5g_fapi_fapi2phy_api.h"
30 #include "nr5g_fapi_fapi2phy_wls.h"
31 #include "nr5g_fapi_log.h"
33 nr5g_fapi_fapi2phy_queue_t fapi2phy_q;
34 nr5g_fapi_fapi2phy_queue_t fapi2phy_q_urllc;
36 //------------------------------------------------------------------------------
37 /** @ingroup group_source_api_fapi2phy
39 * @param[in] p_list_elem Pointer to the ListElement
43 * @description This function adds a ListElement API to a Linked list which will
44 * be sent to L1 once all APIs for a TTI are added
47 //------------------------------------------------------------------------------
48 p_nr5g_fapi_fapi2phy_queue_t nr5g_fapi_fapi2phy_queue(
54 p_nr5g_fapi_fapi2phy_queue_t nr5g_fapi_fapi2phy_queue_urllc(
57 return &fapi2phy_q_urllc;
60 uint8_t nr5g_fapi_get_stats_location(
65 case MSG_TYPE_PHY_CONFIG_REQ:
66 loc = MEM_STAT_CONFIG_REQ;
69 case MSG_TYPE_PHY_START_REQ:
70 loc = MEM_STAT_START_REQ;
73 case MSG_TYPE_PHY_STOP_REQ:
74 loc = MEM_STAT_STOP_REQ;
77 case MSG_TYPE_PHY_SHUTDOWN_REQ:
78 loc = MEM_STAT_SHUTDOWN_REQ;
81 case MSG_TYPE_PHY_DL_CONFIG_REQ:
82 loc = MEM_STAT_DL_CONFIG_REQ;
85 case MSG_TYPE_PHY_UL_CONFIG_REQ:
86 loc = MEM_STAT_UL_CONFIG_REQ;
89 case MSG_TYPE_PHY_UL_DCI_REQ:
90 loc = MEM_STAT_UL_DCI_REQ;
93 case MSG_TYPE_PHY_TX_REQ:
94 loc = MEM_STAT_TX_REQ;
97 case MSG_TYPE_PHY_DL_IQ_SAMPLES:
98 loc = MEM_STAT_DL_IQ_SAMPLES;
101 case MSG_TYPE_PHY_UL_IQ_SAMPLES:
102 loc = MEM_STAT_UL_IQ_SAMPLES;
106 loc = MEM_STAT_DEFAULT;
112 //------------------------------------------------------------------------------
113 /** @ingroup group_source_api_fapi2phy
115 * @param[in] msg_type Message Type
116 * @param[in] num_message_in_blockn Number of Messages in Block
117 * @param[in] align_offset Align Offset
119 * @return Pointer to the List Element structure
121 * @description This function allocates a buffer from shared memory WLS
122 * interface and creates a List Element structures. It then fills
123 * all the fields with data being passed in.
126 //------------------------------------------------------------------------------
127 PMAC2PHY_QUEUE_EL nr5g_fapi_fapi2phy_create_api_list_elem(
129 uint16_t num_message_in_block,
130 uint32_t align_offset)
132 PMAC2PHY_QUEUE_EL p_list_elem = NULL;
135 loc = nr5g_fapi_get_stats_location(msg_type);
136 p_list_elem = (PMAC2PHY_QUEUE_EL) wls_fapi_alloc_buffer(0, loc);
137 //Fill header for link list of API messages
139 p_list_elem->nMessageType = (uint8_t) msg_type;
140 p_list_elem->nNumMessageInBlock = num_message_in_block;
141 p_list_elem->nAlignOffset = (uint16_t) align_offset;
142 p_list_elem->nMessageLen = num_message_in_block * align_offset;
143 p_list_elem->pNext = NULL;
149 //------------------------------------------------------------------------------
150 /** @ingroup group_source_api_fapi2phy
152 * @param[in] p_list_elem Pointer to the ListElement
156 * @description This function adds a ListElement API to a Linked list which will
157 * be sent to L1 once all APIs for a TTI are added
160 //------------------------------------------------------------------------------
161 void nr5g_fapi_fapi2phy_add_to_api_list(
163 PMAC2PHY_QUEUE_EL p_list_elem)
165 p_nr5g_fapi_fapi2phy_queue_t queue = NULL;
171 queue = is_urllc ? nr5g_fapi_fapi2phy_queue_urllc()
172 : nr5g_fapi_fapi2phy_queue();
174 if (queue->p_send_list_head && queue->p_send_list_tail) {
175 queue->p_send_list_tail->pNext = p_list_elem;
176 queue->p_send_list_tail = p_list_elem;
178 queue->p_send_list_head = queue->p_send_list_tail = p_list_elem;
182 //------------------------------------------------------------------------------
183 /** @ingroup group_source_api_fapi2phy
185 * @param A pointer to phy Instance
187 * @return FAPI status
189 * @description This function send API list to L1
192 //------------------------------------------------------------------------------
193 void nr5g_fapi_fapi2phy_send_api_list(
196 uint8_t ret = FAILURE;
197 p_nr5g_fapi_fapi2phy_queue_t queue = NULL;
199 queue = is_urllc ? nr5g_fapi_fapi2phy_queue_urllc()
200 : nr5g_fapi_fapi2phy_queue();
201 if (queue->p_send_list_head) {
203 NR5G_FAPI_LOG(TRACE_LOG,
204 ("[NR5G_FAPI][FAPI2PHY] Sending API's to PHY"));
205 ret = nr5g_fapi_fapi2phy_wls_send(queue->p_send_list_head, is_urllc);
206 if (FAILURE == ret) {
207 NR5G_FAPI_LOG(ERROR_LOG,
208 ("[NR5G_FAPI][FAPI2PHY] Error sending API's to PHY"));
210 queue->p_send_list_tail = queue->p_send_list_head = NULL;
214 //------------------------------------------------------------------------------
215 /** @ingroup group_source_api_fapi2phy
217 * @param[in] A pointer to phy instance
221 * @description The function adds all memory elements to WLS free list
224 //-------------------------------------------------------------------------------------------
226 void nr5g_fapi_fapi2phy_destroy_api_list_elem(
227 PMAC2PHY_QUEUE_EL p_list_elem)
230 uint8_t loc = nr5g_fapi_get_stats_location(p_list_elem->nMessageType);
231 wls_fapi_free_buffer(p_list_elem, loc);