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 SLOT.indication 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"
30 /** @ingroup group_source_api_p7_fapi2mac_proc
32 * @param[in] p_phy_ctx Pointer to PHY context.
33 * @param[in] p_fapi_resp Pointer to IAPI SLOT.indication message structure.
34 * @return Returns ::SUCCESS and ::FAILURE.
37 * This message allows PHY to send slot indication message periodically
38 * to L2/L3 based on the highest numerology cconfigured in CONFIG.request
41 uint8_t nr5g_fapi_slot_indication(
43 p_nr5g_fapi_phy_ctx_t p_phy_ctx,
44 p_fapi_api_stored_vendor_queue_elems vendor_extension_elems,
45 PSlotIndicationStruct p_iapi_resp)
49 fapi_slot_ind_t *p_fapi_slot_ind;
50 p_fapi_api_queue_elem_t p_list_elem;
51 p_nr5g_fapi_phy_instance_t p_phy_instance = NULL;
52 nr5g_fapi_stats_t *p_stats;
54 if (NULL == p_phy_ctx) {
55 NR5G_FAPI_LOG(ERROR_LOG, ("[SLOT.indication] Invalid handle to "
60 if (NULL == p_iapi_resp) {
61 NR5G_FAPI_LOG(ERROR_LOG, ("[SLOT.indication] Invalid handle to iapi "
62 "slot indication message"));
66 for (phy_id = 0; phy_id < FAPI_MAX_PHY_INSTANCES; phy_id++) {
67 if (FAPI_STATE_RUNNING == p_phy_ctx->phy_instance[phy_id].state) {
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,
71 ("[SLOT.indication] Invalid " "phy instance"));
75 p_stats = &p_phy_instance->stats;
76 p_stats->iapi_stats.iapi_slot_ind++;
79 nr5g_fapi_fapi2mac_create_api_list_elem(FAPI_SLOT_INDICATION, 1,
80 sizeof(fapi_slot_ind_t));
83 NR5G_FAPI_LOG(ERROR_LOG, ("[SLOT.indication] Unable to create "
84 "list element. Out of memory!!!"));
88 p_fapi_slot_ind = (fapi_slot_ind_t *) (p_list_elem + 1);
89 p_fapi_slot_ind->header.msg_id = FAPI_SLOT_INDICATION;
90 p_fapi_slot_ind->header.length = (uint16_t) sizeof(fapi_slot_ind_t);
91 p_fapi_slot_ind->sfn = p_iapi_resp->sSFN_Slot.nSFN;
92 p_fapi_slot_ind->slot = p_iapi_resp->sSFN_Slot.nSlot;
94 fapi_vendor_p7_ind_msg_t* p_fapi_vend_p7 =
95 nr5g_fapi_proc_vendor_p7_msg_get(vendor_extension_elems, phy_id);
96 fapi_vendor_ext_slot_ind_t* p_fapi_vend_slot_ind = p_fapi_vend_p7 ? &p_fapi_vend_p7->slot_ind : NULL;
98 if (p_fapi_vend_slot_ind) {
99 p_fapi_vend_slot_ind->carrier_idx = p_iapi_resp->sSFN_Slot.nCarrierIdx;
100 p_fapi_vend_slot_ind->sym = p_iapi_resp->sSFN_Slot.nSym;
103 /* Add element to send list */
104 nr5g_fapi_fapi2mac_add_api_to_list(phy_id, p_list_elem, is_urllc);
106 p_stats->fapi_stats.fapi_slot_ind++;
107 NR5G_FAPI_LOG(DEBUG_LOG, ("[SLOT.indication][%u][%u,%u,%u] is_urllc %u",
108 p_phy_instance->phy_id,
109 p_iapi_resp->sSFN_Slot.nSFN, p_iapi_resp->sSFN_Slot.nSlot,
110 p_iapi_resp->sSFN_Slot.nSym, is_urllc));