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 *******************************************************************************/
20 * @file This file contains implementation of all the functions used
21 * to send APIs from FAPI to PHY
26 #include "nr5g_fapi_internal.h"
27 #include "gnb_l1_l2_api.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;
35 //------------------------------------------------------------------------------
36 /** @ingroup group_source_api_fapi2phy
38 * @param[in] p_list_elem Pointer to the ListElement
42 * @description This function adds a ListElement API to a Linked list which will
43 * be sent to L1 once all APIs for a TTI are added
46 //------------------------------------------------------------------------------
47 p_nr5g_fapi_fapi2phy_queue_t nr5g_fapi_fapi2phy_queue(
53 uint8_t nr5g_fapi_get_stats_location(
58 case MSG_TYPE_PHY_CONFIG_REQ:
59 loc = MEM_STAT_CONFIG_REQ;
62 case MSG_TYPE_PHY_START_REQ:
63 loc = MEM_STAT_START_REQ;
66 case MSG_TYPE_PHY_STOP_REQ:
67 loc = MEM_STAT_STOP_REQ;
70 case MSG_TYPE_PHY_SHUTDOWN_REQ:
71 loc = MEM_STAT_SHUTDOWN_REQ;
74 case MSG_TYPE_PHY_DL_CONFIG_REQ:
75 loc = MEM_STAT_DL_CONFIG_REQ;
78 case MSG_TYPE_PHY_UL_CONFIG_REQ:
79 loc = MEM_STAT_UL_CONFIG_REQ;
82 case MSG_TYPE_PHY_UL_DCI_REQ:
83 loc = MEM_STAT_UL_DCI_REQ;
86 case MSG_TYPE_PHY_TX_REQ:
87 loc = MEM_STAT_TX_REQ;
90 case MSG_TYPE_PHY_DL_IQ_SAMPLES:
91 loc = MEM_STAT_DL_IQ_SAMPLES;
94 case MSG_TYPE_PHY_UL_IQ_SAMPLES:
95 loc = MEM_STAT_UL_IQ_SAMPLES;
99 loc = MEM_STAT_DEFAULT;
105 //------------------------------------------------------------------------------
106 /** @ingroup group_source_api_fapi2phy
108 * @param[in] msg_type Message Type
109 * @param[in] num_message_in_blockn Number of Messages in Block
110 * @param[in] align_offset Align Offset
112 * @return Pointer to the List Element structure
114 * @description This function allocates a buffer from shared memory WLS
115 * interface and creates a List Element structures. It then fills
116 * all the fields with data being passed in.
119 //------------------------------------------------------------------------------
120 PMAC2PHY_QUEUE_EL nr5g_fapi_fapi2phy_create_api_list_elem(
122 uint16_t num_message_in_block,
123 uint32_t align_offset)
125 PMAC2PHY_QUEUE_EL p_list_elem = NULL;
128 loc = nr5g_fapi_get_stats_location(msg_type);
129 p_list_elem = (PMAC2PHY_QUEUE_EL) wls_fapi_alloc_buffer(0, loc);
130 //Fill header for link list of API messages
132 p_list_elem->nMessageType = (uint8_t) msg_type;
133 p_list_elem->nNumMessageInBlock = num_message_in_block;
134 p_list_elem->nAlignOffset = (uint16_t) align_offset;
135 p_list_elem->nMessageLen = num_message_in_block * align_offset;
136 p_list_elem->pNext = NULL;
142 //------------------------------------------------------------------------------
143 /** @ingroup group_source_api_fapi2phy
145 * @param[in] p_list_elem Pointer to the ListElement
149 * @description This function adds a ListElement API to a Linked list which will
150 * be sent to L1 once all APIs for a TTI are added
153 //------------------------------------------------------------------------------
154 void nr5g_fapi_fapi2phy_add_to_api_list(
155 PMAC2PHY_QUEUE_EL p_list_elem)
157 p_nr5g_fapi_fapi2phy_queue_t queue = NULL;
163 queue = nr5g_fapi_fapi2phy_queue();
164 if (queue->p_send_list_head && queue->p_send_list_tail) {
165 queue->p_send_list_tail->pNext = p_list_elem;
166 queue->p_send_list_tail = p_list_elem;
168 queue->p_send_list_head = queue->p_send_list_tail = p_list_elem;
172 //------------------------------------------------------------------------------
173 /** @ingroup group_source_api_fapi2phy
175 * @param A pointer to phy Instance
177 * @return FAPI status
179 * @description This function send API list to L1
182 //------------------------------------------------------------------------------
183 void nr5g_fapi_fapi2phy_send_api_list(
186 uint8_t ret = FAILURE;
187 p_nr5g_fapi_fapi2phy_queue_t queue = NULL;
189 queue = nr5g_fapi_fapi2phy_queue();
190 if (queue->p_send_list_head) {
192 NR5G_FAPI_LOG(TRACE_LOG,
193 ("[NR5G_FAPI][FAPI2PHY] Sending API's to PHY"));
194 ret = nr5g_fapi_fapi2phy_wls_send(queue->p_send_list_head);
195 if (FAILURE == ret) {
196 NR5G_FAPI_LOG(ERROR_LOG,
197 ("[NR5G_FAPI][FAPI2PHY] Error sending API's to PHY"));
199 queue->p_send_list_tail = queue->p_send_list_head = NULL;
203 //------------------------------------------------------------------------------
204 /** @ingroup group_source_api_fapi2phy
206 * @param[in] A pointer to phy instance
210 * @description The function adds all memory elements to WLS free list
213 //-------------------------------------------------------------------------------------------
215 void nr5g_fapi_fapi2phy_destroy_api_list_elem(
216 PMAC2PHY_QUEUE_EL p_list_elem)
219 uint8_t loc = nr5g_fapi_get_stats_location(p_list_elem->nMessageType);
220 wls_fapi_free_buffer(p_list_elem, loc);