* INTC Contribution to the O-RAN F Release for O-DU Low
[o-du/phy.git] / fapi_5g / source / api / fapi2phy / p5 / nr5g_fapi_proc_param_resp.c
1 /******************************************************************************
2 *
3 *   Copyright (c) 2022 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 PARAM.response message.
22  *
23  **/
24
25 #include "nr5g_fapi_framework.h"
26 #include "nr5g_fapi_fapi2mac_api.h"
27 #include "nr5g_fapi_fapi2mac_p5_proc.h"
28
29  /** @ingroup group_source_api_p5_fapi2mac_proc
30  *
31  *  @param[in]  p_phy_instance Pointer to PHY instance.
32  *  @return     Returns ::SUCCESS and ::FAILURE.
33  *
34  *  @description
35  *  This message allows PHY to report L2/L3 about PARAM.request's status.
36  *
37 **/
38 uint8_t nr5g_fapi_param_response(
39     p_nr5g_fapi_phy_instance_t p_phy_instance)
40 {
41     fapi_param_resp_t *p_fapi_resp;
42     p_fapi_api_queue_elem_t p_list_elem;
43     nr5g_fapi_stats_t *p_stats;
44
45     // Create FAPI message header
46     nr5g_fapi_message_header_per_phy(p_phy_instance->phy_id, false);
47
48     p_stats = &p_phy_instance->stats;
49     p_stats->iapi_stats.iapi_param_res++;
50     p_list_elem =
51         nr5g_fapi_fapi2mac_create_api_list_elem(FAPI_PARAM_RESPONSE, 1,
52         sizeof(fapi_param_resp_t));
53     if (!p_list_elem) {
54         NR5G_FAPI_LOG(ERROR_LOG, ("[PARAM.response] Unable to create "
55                 "list element. Out of memory!!!"));
56         return FAILURE;
57     }
58
59     p_fapi_resp = (fapi_param_resp_t *) (p_list_elem + 1);
60     p_fapi_resp->header.msg_id = FAPI_PARAM_RESPONSE;
61     p_fapi_resp->header.length = (uint16_t) sizeof(fapi_param_resp_t);
62     p_fapi_resp->error_code =
63         (p_phy_instance->state == FAPI_STATE_RUNNING) ? MSG_INVALID_STATE : MSG_OK;
64
65     /* TLV report is not supported in PHY */
66     p_fapi_resp->number_of_tlvs = 0;
67
68     // Add element to send list
69     nr5g_fapi_fapi2mac_add_api_to_list(p_phy_instance->phy_id, p_list_elem, false);
70
71     p_stats->fapi_stats.fapi_param_res++;
72     NR5G_FAPI_LOG(INFO_LOG, ("[PARAM.response][%d]", p_phy_instance->phy_id));
73     nr5g_fapi_fapi2mac_send_api_list(false);
74
75     return SUCCESS;
76 }