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 *******************************************************************************/
21 * This file consist of implementation of FAPI CRC.indication message.
25 #include "nr5g_fapi_framework.h"
26 #include "gnb_l1_l2_api.h"
27 #include "nr5g_fapi_fapi2mac_api.h"
28 #include "nr5g_fapi_fapi2mac_p7_proc.h"
29 #include "nr5g_fapi_fapi2mac_p7_pvt_proc.h"
31 /** @ingroup group_source_api_p7_fapi2mac_proc
33 * @param[in] p_phy_ctx Pointer to PHY Context.
34 * @param[in] p_phy_rx_data_ind Pointer to FAPI RX_DATA.indication message structure.
36 * @return Returns ::SUCCESS and ::FAILURE.
39 * This message includes RX_DATA to be sent to L2.
42 uint8_t nr5g_fapi_rx_data_indication(
43 p_nr5g_fapi_phy_ctx_t p_phy_ctx,
44 PRXULSCHIndicationStruct p_phy_rx_ulsch_ind)
48 fapi_rx_data_indication_t *p_fapi_rx_data_ind;
49 p_fapi_api_queue_elem_t p_list_elem;
50 p_nr5g_fapi_phy_instance_t p_phy_instance = NULL;
51 nr5g_fapi_stats_t *p_stats;
53 if (NULL == p_phy_ctx) {
54 NR5G_FAPI_LOG(ERROR_LOG, ("[NR5G_FAPI][RX_DATA.indication] Invalid "
59 if (NULL == p_phy_rx_ulsch_ind) {
60 NR5G_FAPI_LOG(ERROR_LOG, ("[NR5G_FAPI][RX_DATA.indication] Invalid "
61 "RX_USLCH indication"));
65 phy_id = p_phy_rx_ulsch_ind->sSFN_Slot.nCarrierIdx;
66 p_phy_instance = &p_phy_ctx->phy_instance[phy_id];
67 if (p_phy_instance->phy_id != phy_id) {
68 NR5G_FAPI_LOG(ERROR_LOG, ("[NR5G_FAPI][RX_DATA.indication] Invalid "
69 "handle to phy instance"));
73 p_stats = &p_phy_instance->stats;
74 p_stats->iapi_stats.iapi_rx_data_ind++;
76 nr5g_fapi_fapi2mac_create_api_list_elem(FAPI_RX_DATA_INDICATION, 1,
77 sizeof(fapi_rx_data_indication_t));
79 NR5G_FAPI_LOG(ERROR_LOG,
80 ("[NR5G_FAPI][RX_DATA.indication] Unable to create "
81 "list element. Out of memory!!!"));
85 p_fapi_rx_data_ind = (fapi_rx_data_indication_t *) (p_list_elem + 1);
86 p_fapi_rx_data_ind->header.msg_id = FAPI_RX_DATA_INDICATION;
87 p_fapi_rx_data_ind->header.length =
88 (uint16_t) sizeof(fapi_rx_data_indication_t);
90 if (nr5g_fapi_rx_data_indication_to_fapi_translation(p_phy_instance,
91 p_phy_rx_ulsch_ind, p_fapi_rx_data_ind)) {
92 NR5G_FAPI_LOG(ERROR_LOG, ("[NR5G_FAPI][RX_DATA.indication] L1 to FAPI "
93 "translation failed"));
97 nr5g_fapi_fapi2mac_add_api_to_list(phy_id, p_list_elem);
99 p_stats->fapi_stats.fapi_rx_data_ind++;
100 NR5G_FAPI_LOG(DEBUG_LOG, ("[NR5G_FAPI][%d][%d,%d]",
101 p_phy_instance->phy_id,
102 p_phy_rx_ulsch_ind->sSFN_Slot.nSFN,
103 p_phy_rx_ulsch_ind->sSFN_Slot.nSlot));
108 /** @ingroup group_source_api_p7_fapi2mac_proc
110 * @param[in] ue_id Variable holding ue_id received in RX_DATA.Indication..
111 * @param[in] p_ul_slot_info Pointer to ul slot info structure that stores the
112 * UL_TTI.request PDU info.
114 * @return Returns Pointer to pusch info, if handle of p_ul_slot_info matches ue_id.
115 NULL, if handle of p_ul_slot_info not matches ue_id
118 * This function retrieves the pusch info stored during corresponding UL_TTI.request processing.
122 nr5g_fapi_pusch_info_t *nr5g_fapi_get_pusch_info(
124 nr5g_fapi_ul_slot_info_t * p_ul_slot_info)
126 uint8_t i, num_ulsch;
128 nr5g_fapi_pusch_info_t *p_pusch_info;
130 num_ulsch = p_ul_slot_info->num_ulsch;
131 for (i = 0; i < num_ulsch; i++) {
132 p_pusch_info = &p_ul_slot_info->pusch_info[i];
133 if (p_pusch_info->handle == ue_id) {
140 /** @ingroup group_source_api_p7_fapi2mac_proc
142 * @param[in] p_phy_instance Pointer to PHY instance.
143 * @param[in] p_phy_rx_ulsch_ind Pointer to IAPI RX_ULSCH.indication structure.
144 * @param[out] p_fapi_rx_data_ind Pointer to FAPI RX_DATA.indication structure.
146 * @return Returns ::SUCCESS and ::FAILURE.
149 * This function converts IAPI RX_DATA.indication to FAPI CRC.indication
153 uint8_t nr5g_fapi_rx_data_indication_to_fapi_translation(
154 p_nr5g_fapi_phy_instance_t p_phy_instance,
155 PRXULSCHIndicationStruct p_phy_rx_ulsch_ind,
156 fapi_rx_data_indication_t * p_fapi_rx_data_ind)
158 uint8_t num_ulsch, i;
162 nr5g_fapi_pusch_info_t *p_pusch_info;
163 fapi_pdu_ind_info_t *p_fapi_pdu_ind_info;
164 nr5g_fapi_ul_slot_info_t *p_ul_slot_info;
165 nr5g_fapi_stats_t *p_stats;
166 ULSCHPDUDataStruct *p_rx_ulsch_pdu_data;
168 p_stats = &p_phy_instance->stats;
170 frame_no = p_fapi_rx_data_ind->sfn = p_phy_rx_ulsch_ind->sSFN_Slot.nSFN;
171 slot_no = p_fapi_rx_data_ind->slot = p_phy_rx_ulsch_ind->sSFN_Slot.nSlot;
174 nr5g_fapi_get_ul_slot_info(frame_no, slot_no, p_phy_instance);
176 if (p_ul_slot_info == NULL) {
177 NR5G_FAPI_LOG(ERROR_LOG,
178 ("[NR5G_FAPI] [RX_DATA.indication] No Valid data available "
179 "for frame :%d and slot: %d", frame_no, slot_no));
183 num_ulsch = p_fapi_rx_data_ind->numPdus = p_phy_rx_ulsch_ind->nUlsch;
184 for (i = 0; i < num_ulsch; i++) {
185 p_stats->iapi_stats.iapi_rx_data_ind_pdus++;
186 p_fapi_pdu_ind_info = &p_fapi_rx_data_ind->pdus[i];
187 p_rx_ulsch_pdu_data = &p_phy_rx_ulsch_ind->sULSCHPDUDataStruct[i];
189 nr5g_fapi_get_pusch_info(p_rx_ulsch_pdu_data->nUEId,
191 if (p_pusch_info == NULL) {
192 NR5G_FAPI_LOG(ERROR_LOG,
193 ("[NR5G_FAPI] [RX_DATA.indication] No Valid data available "
194 "nUEId:%d, frame_no:%d, slot_no:%d",
195 p_rx_ulsch_pdu_data->nUEId, frame_no, slot_no));
199 p_fapi_pdu_ind_info->handle = p_pusch_info->handle;
200 p_fapi_pdu_ind_info->rnti = p_rx_ulsch_pdu_data->nRNTI;
201 p_fapi_pdu_ind_info->harqId = p_pusch_info->harq_process_id;
202 p_fapi_pdu_ind_info->ul_cqi = p_pusch_info->ul_cqi;
203 p_fapi_pdu_ind_info->timingAdvance = p_pusch_info->timing_advance;
204 p_fapi_pdu_ind_info->rssi = 880;
205 p_fapi_pdu_ind_info->pdu_length = p_rx_ulsch_pdu_data->nPduLen;
206 p_fapi_pdu_ind_info->pduData = (void *)p_rx_ulsch_pdu_data->pPayload;
208 p_stats->fapi_stats.fapi_rx_data_ind_pdus++;