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 *******************************************************************************/
21 * This file consist of implementation of FAPI UCI.indication on PUSCH message.
25 #include "nr5g_mac_phy_api.h"
26 #include "nr5g_fapi_framework.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"
30 #include "nr5g_fapi_memory.h"
32 /** @ingroup group_source_api_p7_fapi2mac_proc
34 * @param[in] p_phy_ctx Pointer to PHY Context.
35 * @param[in] p_phy_rx_ulsch_uci_ind Pointer to IAPI RX_ULSCH_UCI.indication message structure.
37 * @return Returns ::SUCCESS and ::FAILURE.
40 * This message includes UCI payload on PUSCH.
43 uint8_t nr5g_fapi_rx_data_uci_indication(
45 p_nr5g_fapi_phy_ctx_t p_phy_ctx,
46 PRXULSCHUCIIndicationStruct p_phy_rx_ulsch_uci_ind)
50 fapi_uci_indication_t *p_fapi_uci_ind;
51 p_fapi_api_queue_elem_t p_list_elem;
52 p_nr5g_fapi_phy_instance_t p_phy_instance = NULL;
53 nr5g_fapi_stats_t *p_stats;
55 if (NULL == p_phy_ctx) {
56 NR5G_FAPI_LOG(ERROR_LOG, ("[UCI.indication on PUSCH] Invalid Phy "
61 if (NULL == p_phy_rx_ulsch_uci_ind) {
62 NR5G_FAPI_LOG(ERROR_LOG, ("[UCI.indication on PUSCH] Invalid Phy "
63 "RX_ULSCH_UCI indication"));
67 phy_id = p_phy_rx_ulsch_uci_ind->sSFN_Slot.nCarrierIdx;
68 p_phy_instance = &p_phy_ctx->phy_instance[phy_id];
69 if (p_phy_instance->phy_id != phy_id) {
70 NR5G_FAPI_LOG(ERROR_LOG, ("[UCI.indication on PUSCH] Invalid Phy "
75 p_stats = &p_phy_instance->stats;
76 p_stats->iapi_stats.iapi_uci_ind++;
79 nr5g_fapi_fapi2mac_create_api_list_elem(FAPI_UCI_INDICATION, 1,
80 sizeof(fapi_uci_indication_t));
82 NR5G_FAPI_LOG(ERROR_LOG, ("[UCI.indication on PUSCH] Unable to create "
83 "list element. Out of memory!!!"));
87 p_fapi_uci_ind = (fapi_uci_indication_t *) (p_list_elem + 1);
88 p_fapi_uci_ind->header.msg_id = FAPI_UCI_INDICATION;
89 p_fapi_uci_ind->header.length = sizeof(fapi_uci_indication_t);
91 if (nr5g_fapi_rx_data_uci_indication_to_fapi_translation(p_phy_instance,
92 p_phy_rx_ulsch_uci_ind, p_fapi_uci_ind)) {
93 NR5G_FAPI_LOG(ERROR_LOG,
94 ("[UCI.indication on PUSCH] FAPI to L1 " "translation failed"));
98 nr5g_fapi_fapi2mac_add_api_to_list(phy_id, p_list_elem, is_urllc);
100 p_stats->fapi_stats.fapi_uci_ind++;
102 NR5G_FAPI_LOG(DEBUG_LOG, ("[UCI.indication on PUSCH][%u][%u,%u,%u] is_urllc %u",
103 p_phy_instance->phy_id,p_phy_rx_ulsch_uci_ind->sSFN_Slot.nSFN,
104 p_phy_rx_ulsch_uci_ind->sSFN_Slot.nSlot,
105 p_phy_rx_ulsch_uci_ind->sSFN_Slot.nSym, is_urllc));
110 /** @ingroup group_source_api_p7_fapi2mac_proc
112 * @param[in] p_phy_instance Pointer to PHY instance.
113 * @param[in] p_phy_uci_ind Pointer to IAPI RX_ULSCH_UCI.indication structure.
114 * @param[out] p_fapi_uci_ind Pointer to FAPI UCI.indication structure.
116 * @return Returns ::SUCCESS and ::FAILURE.
119 * This function converts IAPI RX_ULSCH_UCI.indication to FAPI UCI.indication
123 uint8_t nr5g_fapi_rx_data_uci_indication_to_fapi_translation(
124 p_nr5g_fapi_phy_instance_t p_phy_instance,
125 PRXULSCHUCIIndicationStruct p_phy_rx_ulsch_uci_ind,
126 fapi_uci_indication_t * p_fapi_uci_ind)
129 uint8_t nUciDetected, nUciCsiP1Detected, nUciCsiP2Detected;
131 PULSCHUCIPDUDataStruct p_phy_uci_pdu_data_struct;
132 fapi_uci_pdu_info_t *p_fapi_uci_pdu_info;
133 fapi_uci_o_pusch_t *p_uci_push;
134 nr5g_fapi_stats_t *p_stats;
136 p_stats = &p_phy_instance->stats;
138 p_fapi_uci_ind->sfn = p_phy_rx_ulsch_uci_ind->sSFN_Slot.nSFN;
139 p_fapi_uci_ind->slot = p_phy_rx_ulsch_uci_ind->sSFN_Slot.nSlot;
141 num_uci = p_fapi_uci_ind->numUcis = p_phy_rx_ulsch_uci_ind->nUlschUci;
143 for (i = 0; i < num_uci; i++) {
144 p_stats->iapi_stats.iapi_uci_ind_pdus++;
146 p_fapi_uci_pdu_info = &p_fapi_uci_ind->uciPdu[i];
147 p_phy_uci_pdu_data_struct =
148 &p_phy_rx_ulsch_uci_ind->sULSCHUCIPDUDataStruct[i];
150 p_fapi_uci_pdu_info->pduType = 0;
151 p_fapi_uci_pdu_info->pduSize = sizeof(fapi_uci_o_pusch_t);
153 p_uci_push = &p_fapi_uci_pdu_info->uci.uciPusch;
154 memset(p_uci_push, 0, sizeof(fapi_uci_o_pusch_t));
156 p_uci_push->handle = p_phy_uci_pdu_data_struct->nUEId;
157 p_uci_push->pduBitmap = 0;
158 p_uci_push->ul_cqi = 0xff;
159 p_uci_push->rnti = p_phy_uci_pdu_data_struct->nRNTI;
160 p_uci_push->timingAdvance = 0xffff;
161 p_uci_push->rssi = 0xffff;
163 nUciDetected = p_phy_uci_pdu_data_struct->nUciDetected;
165 p_uci_push->pduBitmap |= 0x02;
166 p_uci_push->harqInfo.harqCrc = p_phy_uci_pdu_data_struct->nUciCrc;
167 p_uci_push->harqInfo.harqBitLen =
168 p_phy_uci_pdu_data_struct->nPduUciAckLen;
169 NR5G_FAPI_MEMCPY(p_uci_push->harqInfo.harqPayload,
170 sizeof(uint8_t) * FAPI_MAX_HARQ_INFO_LEN_BYTES,
171 p_phy_uci_pdu_data_struct->nUciAckBits,
172 sizeof(uint8_t) * FAPI_MAX_HARQ_INFO_LEN_BYTES);
175 nUciCsiP1Detected = p_phy_uci_pdu_data_struct->nUciCsiP1Detected;
176 if (nUciCsiP1Detected) {
177 p_uci_push->pduBitmap |= 0x04;
178 p_uci_push->csiPart1info.csiPart1Crc =
179 p_phy_uci_pdu_data_struct->nUciCsiP1Crc;
180 p_uci_push->csiPart1info.csiPart1BitLen =
181 p_phy_uci_pdu_data_struct->nPduUciCsiP1Len;
182 NR5G_FAPI_MEMCPY(p_uci_push->csiPart1info.csiPart1Payload,
183 sizeof(uint8_t) * FAPI_MAX_CSI_PART1_DATA_BYTES,
184 p_phy_uci_pdu_data_struct->nUciCsiP1Bits,
185 sizeof(uint8_t) * FAPI_MAX_CSI_PART1_DATA_BYTES);
188 nUciCsiP2Detected = p_phy_uci_pdu_data_struct->nUciCsiP2Detected;
189 if (nUciCsiP2Detected) {
190 p_uci_push->pduBitmap |= 0x08;
191 p_uci_push->csiPart2info.csiPart2Crc =
192 p_phy_uci_pdu_data_struct->nUciCsiP2Crc;
193 p_uci_push->csiPart2info.csiPart2BitLen =
194 p_phy_uci_pdu_data_struct->nPduUciCsiP2Len;
195 NR5G_FAPI_MEMCPY(p_uci_push->csiPart2info.csiPart2Payload,
196 sizeof(uint8_t) * FAPI_MAX_CSI_PART2_DATA_BYTES,
197 p_phy_uci_pdu_data_struct->nUciCsiP2Bits,
198 sizeof(uint8_t) * FAPI_MAX_CSI_PART2_DATA_BYTES);
200 p_stats->fapi_stats.fapi_uci_ind_pdus++;