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 MAC
26 #include "nr5g_fapi_internal.h"
27 #include "gnb_l1_l2_api.h"
28 #include "nr5g_fapi_fapi2mac_api.h"
29 #include "nr5g_fapi_fapi2mac_wls.h"
31 static nr5g_fapi_fapi2mac_queue_t fapi2mac_q[FAPI_MAX_PHY_INSTANCES];
33 //------------------------------------------------------------------------------
34 /** @ingroup group_source_api_fapi2phy
36 * @param[in] p_list_elem Pointer to the ListElement
40 * @description This function adds a ListElement API to a Linked list which will
41 * be sent to L1 once all APIs for a TTI are added
44 //------------------------------------------------------------------------------
45 inline p_nr5g_fapi_fapi2mac_queue_t nr5g_fapi_fapi2mac_queue(
48 return &fapi2mac_q[phy_id];
51 //------------------------------------------------------------------------------
52 /** @ingroup group_lte_source_phy_fapi
54 * @param[in] pListElem Pointer to the ListElement
58 * @description This function adds a ListElement API to a Linked list which will
59 * be sent to L1 once all APIs for a TTI are added
62 //------------------------------------------------------------------------------
63 void nr5g_fapi_fapi2mac_add_api_to_list(
65 p_fapi_api_queue_elem_t p_list_elem)
67 p_nr5g_fapi_fapi2mac_queue_t queue = NULL;
68 p_fapi_msg_header_t p_fapi_msg_hdr = NULL;
74 queue = nr5g_fapi_fapi2mac_queue(phy_id);
75 if (queue->p_send_list_head && queue->p_send_list_tail) {
76 p_fapi_msg_hdr = (p_fapi_msg_header_t) (queue->p_send_list_head + 1);
77 p_fapi_msg_hdr->num_msg += 1;
78 queue->p_send_list_tail->p_next = p_list_elem;
79 queue->p_send_list_tail = p_list_elem;
81 queue->p_send_list_head = queue->p_send_list_tail = p_list_elem;
85 //------------------------------------------------------------------------------
86 /** @ingroup group_lte_source_phy_fapi
88 * @param A pointer to phy Instance
92 * @description This function send API list to L1
95 //------------------------------------------------------------------------------
96 void nr5g_fapi_fapi2mac_send_api_list(
100 p_fapi_api_queue_elem_t p_commit_list_head = NULL;
101 p_fapi_api_queue_elem_t p_commit_list_tail = NULL;
102 p_nr5g_fapi_fapi2mac_queue_t queue = NULL;
104 for (phy_id = 0; phy_id < FAPI_MAX_PHY_INSTANCES; phy_id++) {
105 queue = nr5g_fapi_fapi2mac_queue(phy_id);
106 if (queue->p_send_list_head && queue->p_send_list_tail) {
107 if (p_commit_list_head && p_commit_list_tail) {
108 p_commit_list_tail->p_next = queue->p_send_list_head;
109 p_commit_list_tail = queue->p_send_list_tail;
111 p_commit_list_head = queue->p_send_list_head;
112 p_commit_list_tail = queue->p_send_list_tail;
114 queue->p_send_list_head = queue->p_send_list_tail = NULL;
118 if (p_commit_list_head)
119 nr5g_fapi_fapi2mac_wls_send(p_commit_list_head);
122 //------------------------------------------------------------------------------
123 /** @ingroup group_lte_source_phy_fapi
125 * @param[in] phyInstance PhyInstance Id
126 * @param[in] NumMessageInBlock Number of Messages in Block
127 * @param[in] AlignOffset Align Offset
128 * @param[in] MsgType Message Type
129 * @param[in] FrameNum Frame Number
130 * @param[in] subFrameNum subframe Number
132 * @return Pointer to the List Element structure
134 * @description This function allocates a buffer from shared memory WLS
135 * interface and creates a List Element structures. It then fills
136 * all the fields with data being passed in.
139 //------------------------------------------------------------------------------
140 p_fapi_api_queue_elem_t nr5g_fapi_fapi2mac_create_api_list_elem(
142 uint16_t num_message_in_block,
143 uint32_t align_offset)
145 p_fapi_api_queue_elem_t p_list_elem = NULL;
147 p_list_elem = (p_fapi_api_queue_elem_t)
148 nr5g_fapi_fapi2mac_wls_alloc_buffer();
149 //Fill header for link list of API messages
151 p_list_elem->msg_type = (uint8_t) msg_type;
152 p_list_elem->num_message_in_block = num_message_in_block;
153 p_list_elem->align_offset = (uint16_t) align_offset;
154 p_list_elem->msg_len = num_message_in_block * align_offset;
155 p_list_elem->p_next = NULL;
156 p_list_elem->p_tx_data_elm_list = NULL;
157 p_list_elem->time_stamp = 0;