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 *******************************************************************************/
19 #include "nr5g_mac_phy_api.h"
20 #include "nr5g_fapi_framework.h"
21 #include "nr5g_fapi_fapi2mac_api.h"
22 #include "nr5g_fapi_fapi2mac_p7_proc.h"
25 static inline p_fapi_api_queue_elem_t alloc_vendor_p7_msg()
27 p_fapi_api_queue_elem_t p_vend_elem = nr5g_fapi_fapi2mac_create_api_list_elem(
28 FAPI_VENDOR_EXT_P7_IND,
29 1, sizeof(fapi_vendor_p7_ind_msg_t));
33 fapi_vendor_p7_ind_msg_t* p_vend_p7_ind = (fapi_vendor_p7_ind_msg_t*) (p_vend_elem + 1);
34 p_vend_p7_ind->header.msg_id = FAPI_VENDOR_EXT_P7_IND;
35 p_vend_p7_ind->header.length = (uint16_t) sizeof(fapi_vendor_p7_ind_msg_t);
39 NR5G_FAPI_LOG(ERROR_LOG, ("[VENDOR EXT indication] Unable to create "
40 "list element. Out of memory!!!"));
46 /** @ingroup group_source_api_p7_fapi2mac_proc
48 * @return Returns pointer to fapi_vendor_p7_ind_msg_t
51 * Used to access fapi_vendor_p7_ind_msg_t for filling.
52 * Allocates the message if it's not allocated yet.
55 fapi_vendor_p7_ind_msg_t* nr5g_fapi_proc_vendor_p7_msg_get(
56 p_fapi_api_stored_vendor_queue_elems vendor_extension_elems,
59 if(phy_id >= FAPI_MAX_PHY_INSTANCES)
61 NR5G_FAPI_LOG(ERROR_LOG, ("[VENDOR EXT indication] Out of bounds"
62 "phy_id=%u", phy_id));
66 p_fapi_api_queue_elem_t p_vend_elem = vendor_extension_elems->vendor_ext[phy_id];
69 NR5G_FAPI_LOG(DEBUG_LOG, ("[VENDOR EXT indication] No vendor element"
70 "for phy_id=%u yet. Creating new", phy_id));
71 p_vend_elem = alloc_vendor_p7_msg();
72 vendor_extension_elems->vendor_ext[phy_id] = p_vend_elem;
75 return p_vend_elem ? (fapi_vendor_p7_ind_msg_t*) (p_vend_elem + 1) : NULL;
78 /** @ingroup group_source_api_p7_fapi2mac_proc
83 * Adds all cached vendor msgs to api list.
84 * Function shall be called after all other fapi msgs are added.
87 void nr5g_fapi_proc_vendor_p7_msgs_move_to_api_list(
89 p_fapi_api_stored_vendor_queue_elems vendor_extension_elems)
92 for(phy_id=0; phy_id<FAPI_MAX_PHY_INSTANCES; phy_id++)
94 p_fapi_api_queue_elem_t* p_vend_elem = &(vendor_extension_elems->vendor_ext[phy_id]);
95 nr5g_fapi_fapi2mac_add_api_to_list(phy_id, *p_vend_elem, is_urllc);