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 CONFIG.response 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_p5_proc.h"
30 /** @ingroup group_source_api_p5_fapi2mac_proc
32 * @param[in] p_phy_instance Pointer to PHY instance.
33 * @param[in] p_fapi_resp Pointer to IAPI CONFIG.response message structure.
34 * @return Returns ::SUCCESS and ::FAILURE.
37 * This message allows PHY to report L2/L3 about CONFIG.request's status.
40 uint8_t nr5g_fapi_config_response(
41 p_nr5g_fapi_phy_ctx_t p_phy_ctx,
42 PCONFIGRESPONSEStruct p_iapi_resp)
45 fapi_config_resp_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 nr5g_fapi_stats_t *p_stats;
50 if (NULL == p_phy_ctx) {
51 NR5G_FAPI_LOG(ERROR_LOG, ("[CONFIG.response] Invalid " "phy context"));
55 if (NULL == p_iapi_resp) {
56 NR5G_FAPI_LOG(ERROR_LOG, ("[CONFIG.response] Invalid iapi "
57 "config response message"));
61 phy_id = p_iapi_resp->nCarrierIdx;
62 p_phy_instance = &p_phy_ctx->phy_instance[phy_id];
63 if (p_phy_instance->phy_id != phy_id) {
64 NR5G_FAPI_LOG(ERROR_LOG, ("[CONFIG.response] Invalid " "phy instance"));
67 // Create FAPI message header
68 if (FAPI_STATE_IDLE == p_phy_instance->state)
69 nr5g_fapi_message_header_per_phy(phy_id, false);
71 p_stats = &p_phy_instance->stats;
72 p_stats->iapi_stats.iapi_config_res++;
74 nr5g_fapi_fapi2mac_create_api_list_elem(FAPI_CONFIG_RESPONSE, 1,
75 sizeof(fapi_config_resp_t));
77 NR5G_FAPI_LOG(ERROR_LOG, ("[CONFIG.response] Unable to create "
78 "list element. Out of memory!!!"));
82 p_fapi_resp = (fapi_config_resp_t *) (p_list_elem + 1);
83 p_fapi_resp->header.msg_id = FAPI_CONFIG_RESPONSE;
84 p_fapi_resp->header.length = (uint16_t) sizeof(fapi_config_resp_t);
85 p_fapi_resp->error_code = p_iapi_resp->nStatus;
87 if (FAPI_STATE_IDLE == p_phy_instance->state && 0 == p_iapi_resp->nStatus) {
88 p_phy_ctx->num_phy_instance += 1;
89 p_phy_instance->state = FAPI_STATE_CONFIGURED;
91 // TODO: Update phy_id to 0 in phy_instance on error.
93 /* TLV report is not supported in PHY */
94 p_fapi_resp->number_of_invalid_tlvs = 0;
95 p_fapi_resp->number_of_inv_tlvs_idle_only = 0;
96 p_fapi_resp->number_of_inv_tlvs_running_only = 0;
97 p_fapi_resp->number_of_missing_tlvs = 0;
99 // Add element to send list
100 nr5g_fapi_fapi2mac_add_api_to_list(phy_id, p_list_elem, false);
102 p_stats->fapi_stats.fapi_config_res++;
103 NR5G_FAPI_LOG(INFO_LOG, ("[CONFIG.response][%d]", phy_id));