* INTC Contribution to the O-RAN F Release for O-DU Low
[o-du/phy.git] / fapi_5g / source / api / fapi2mac / p5 / nr5g_fapi_proc_dl_iq_samples_resp.c
1 /******************************************************************************
2 *
3 *   Copyright (c) 2021 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 DL_IQ_SAMPLES.response message.
22  *
23  **/
24 #include "nr5g_fapi_framework.h"
25 #include "nr5g_fapi_fapi2mac_api.h"
26 #include "nr5g_fapi_fapi2mac_p5_proc.h"
27
28 #ifdef DEBUG_MODE
29  /** @ingroup group_source_api_p5_fapi2phy_proc
30  *
31  *  @param[in]  p_phy_ctx Pointer to PHY context.
32  *  @param[in]  p_fapi_resp Pointer to IAPI DL_IQ_SAMPLES.response message structure.
33  *  @return     Returns ::SUCCESS and ::FAILURE.
34  *
35  *  @description
36  *  This timer mode vendor specific message used for acknowledging the DL_IQ_SAMPLES.Request
37  *  message used by TestMAC to validate Downlink messages
38  *
39 **/
40 uint8_t nr5g_fapi_dl_iq_samples_response(
41     p_nr5g_fapi_phy_ctx_t p_phy_ctx,
42     PADD_REMOVE_BBU_CORES_NR5G p_iapi_resp)
43 {
44     uint8_t phy_id;
45     fapi_vendor_ext_dl_iq_samples_res_t *p_fapi_resp;
46     p_fapi_api_queue_elem_t p_list_elem;
47     p_nr5g_fapi_phy_instance_t p_phy_instance = NULL;
48
49     if (NULL == p_phy_ctx) {
50         NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_SAMPLES.response] Invalid "
51                 "phy ctx"));
52         return FAILURE;
53     }
54
55     if (NULL == p_iapi_resp) {
56         NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_SAMPLES.response] Invalid iapi "
57                 "message"));
58         return FAILURE;
59     }
60
61     phy_id = p_iapi_resp->sSFN_Slot.nCarrierIdx;
62     p_phy_instance = &p_phy_ctx->phy_instance[phy_id];
63
64     if (p_phy_instance->phy_id != phy_id) {
65         NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_SAMPLES.response] Invalid "
66                 "phy instance"));
67         return FAILURE;
68     }
69
70     p_list_elem =
71         nr5g_fapi_fapi2mac_create_api_list_elem(FAPI_VENDOR_EXT_DL_IQ_SAMPLES,
72         1, sizeof(fapi_vendor_ext_dl_iq_samples_res_t));
73     if (!p_list_elem) {
74         NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_SAMPLES.response] Unable to create "
75                 "list element. Out of memory!!!"));
76         return FAILURE;
77     }
78
79     p_fapi_resp = (fapi_vendor_ext_dl_iq_samples_res_t *) (p_list_elem + 1);
80     p_fapi_resp->header.msg_id = FAPI_VENDOR_EXT_DL_IQ_SAMPLES;
81     p_fapi_resp->header.length =
82         (uint16_t) sizeof(fapi_vendor_ext_dl_iq_samples_res_t);
83
84     /* Add element to send list */
85     nr5g_fapi_fapi2mac_add_api_to_list(phy_id, p_list_elem, false);
86
87     NR5G_FAPI_LOG(INFO_LOG, ("[DL_IQ_SAMPLES.response][%d]", phy_id));
88
89     nr5g_fapi_clean(p_phy_instance);
90     return SUCCESS;
91 }
92 #endif