Update to odulow per maintenance bronze
[o-du/phy.git] / fapi_5g / source / api / fapi2mac / p5 / nr5g_fapi_proc_ul_iq_samples_resp.c
1 /******************************************************************************
2 *
3 *   Copyright (c) 2019 Intel.
4 *
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
8 *
9 *       http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 *
17 *******************************************************************************/
18
19 /**
20  * @file
21  * This file consist of implementation of FAPI ULIQ_Samples.response message.
22  *
23  **/
24 #include "nr5g_fapi_framework.h"
25 #include "gnb_l1_l2_api.h"
26 #include "nr5g_fapi_fapi2mac_api.h"
27 #include "nr5g_fapi_fapi2mac_p5_proc.h"
28
29 #ifdef DEBUG_MODE
30  /** @ingroup group_source_api_p5_fapi2phy_proc
31  *
32  *  @param[in]  p_phy_instance Pointer to PHY instance.
33  *  @param[in]  p_fapi_resp Pointer to IAPI ULIQ_Samples.response message structure.
34  *  @return     Returns ::SUCCESS and ::FAILURE.
35  *
36  *  @description
37  *  This timer mode vendor specific message used for acknowledging the ULIQ_Samples.Request
38  *  message used by TestMAC to validate uplink message indications. 
39  *
40 **/
41 uint8_t nr5g_fapi_ul_iq_samples_response(
42     p_nr5g_fapi_phy_ctx_t p_phy_ctx,
43     PADD_REMOVE_BBU_CORES p_iapi_resp)
44 {
45     uint8_t phy_id;
46     fapi_vendor_ext_ul_iq_samples_res_t *p_fapi_resp;
47     p_fapi_api_queue_elem_t p_list_elem;
48     p_nr5g_fapi_phy_instance_t p_phy_instance = NULL;
49
50     if (NULL == p_phy_ctx) {
51         NR5G_FAPI_LOG(ERROR_LOG, ("[UL_IQ_SAMPLES.response] Invalid handle to "
52                 "phy instance"));
53         return FAILURE;
54     }
55
56     if (NULL == p_iapi_resp) {
57         NR5G_FAPI_LOG(ERROR_LOG, ("[UL_IQ_SAMPLES.response] Invalid IAPI "
58                 "ULIQ_Samples response message"));
59         return FAILURE;
60     }
61
62     phy_id = p_iapi_resp->sSFN_Slot.nCarrierIdx;
63     p_phy_instance = &p_phy_ctx->phy_instance[phy_id];
64     // Create FAPI message header
65     if (p_phy_instance->state == FAPI_STATE_IDLE) {
66         nr5g_fapi_message_header_per_phy(phy_id);
67     }
68
69     p_list_elem =
70         nr5g_fapi_fapi2mac_create_api_list_elem(FAPI_VENDOR_EXT_UL_IQ_SAMPLES,
71         1, sizeof(fapi_vendor_ext_ul_iq_samples_res_t));
72     if (!p_list_elem) {
73         NR5G_FAPI_LOG(ERROR_LOG, ("[UL_IQ_SAMPLES.response] Unable to create "
74                 "list element. Out of memory!!!"));
75         return FAILURE;
76     }
77
78     p_fapi_resp = (fapi_vendor_ext_ul_iq_samples_res_t *) (p_list_elem + 1);
79     p_fapi_resp->header.msg_id = FAPI_VENDOR_EXT_UL_IQ_SAMPLES;
80     p_fapi_resp->header.length =
81         (uint16_t) sizeof(fapi_vendor_ext_ul_iq_samples_res_t);
82
83     /* Add element to send list */
84     nr5g_fapi_fapi2mac_add_api_to_list(phy_id, p_list_elem);
85
86     NR5G_FAPI_LOG(INFO_LOG, ("[UL_IQ_SAMPLES.response]%d]", phy_id));
87
88     return SUCCESS;
89 }
90 #endif