FAPI TM, WLS_LIB and ODULOW documentation
[o-du/phy.git] / fapi_5g / source / api / fapi2phy / p5 / nr5g_fapi_proc_shutdown_req.c
1 /******************************************************************************
2 *
3 *   Copyright (c) 2019 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 Start.request message.
22  *
23  **/
24
25 #include "nr5g_fapi_framework.h"
26 #include "gnb_l1_l2_api.h"
27 #include "nr5g_fapi_fapi2mac_api.h"
28 #include "nr5g_fapi_fapi2phy_api.h"
29 #include "nr5g_fapi_fapi2phy_p5_proc.h"
30 #include "nr5g_fapi_fapi2phy_p5_pvt_proc.h"
31
32  /** @ingroup group_source_api_p5_fapi2phy_proc
33  *
34  *  @param[in]  p_phy_instance Pointer to PHY instance.
35  *  @param[in]  p_fapi_req Pointer to FAPI SHUTDOWN.request message structure.
36  *  @return     Returns ::SUCCESS and ::FAILURE.
37  *
38  *  @description
39  *  This vendor specific message  instructs a configured PHY to Shutdown its processing 
40  *  by cleaning up the resources alloted when PHY is up and running.
41  *
42 **/
43 uint8_t nr5g_fapi_shutdown_request(
44     p_nr5g_fapi_phy_instance_t p_phy_instance,
45     fapi_vendor_ext_shutdown_req_t * p_fapi_req)
46 {
47     PSHUTDOWNREQUESTStruct p_shutdown_req;
48     PMAC2PHY_QUEUE_EL p_list_elem;
49     nr5g_fapi_stats_t *p_stats;
50
51     if (NULL == p_phy_instance) {
52         NR5G_FAPI_LOG(ERROR_LOG, ("[SHUTDOWN.request] Invalid "
53                 "phy instance"));
54         return FAILURE;
55     }
56     p_stats = &p_phy_instance->stats;
57     p_stats->fapi_stats.fapi_vext_shutdown_req++;
58
59     if (NULL == p_fapi_req) {
60         NR5G_FAPI_LOG(ERROR_LOG, ("[SHUTDOWN.request] Invalid handle to fapi "
61                 "message"));
62         return FAILURE;
63     }
64
65     p_list_elem = nr5g_fapi_fapi2phy_create_api_list_elem((uint8_t)
66         MSG_TYPE_PHY_SHUTDOWN_REQ, 1, (uint32_t) sizeof(SHUTDOWNREQUESTStruct));
67     if (!p_list_elem) {
68         NR5G_FAPI_LOG(ERROR_LOG, ("[SHUTDOWN.request] Unable to create "
69                 "list element. Out of memory!!!"));
70         return FAILURE;
71     }
72     p_shutdown_req = (PSHUTDOWNREQUESTStruct) (p_list_elem + 1);
73     p_shutdown_req->sMsgHdr.nMessageType = MSG_TYPE_PHY_SHUTDOWN_REQ;
74     p_shutdown_req->sMsgHdr.nMessageLen =
75         (uint16_t) sizeof(SHUTDOWNREQUESTStruct);
76     p_shutdown_req->sSFN_Slot.nSFN = p_fapi_req->sfn;
77     p_shutdown_req->sSFN_Slot.nSlot = p_fapi_req->slot;
78     p_shutdown_req->sSFN_Slot.nCarrierIdx = p_phy_instance->phy_id;
79     p_phy_instance->shutdown_test_type = p_shutdown_req->nTestType =
80         p_fapi_req->test_type;
81
82     /* Add element to send list */
83     nr5g_fapi_fapi2phy_add_to_api_list(p_list_elem);
84
85     p_stats->iapi_stats.iapi_shutdown_req++;
86     NR5G_FAPI_LOG(INFO_LOG, ("[SHUTDOWN.request][%d]", p_phy_instance->phy_id));
87
88     return SUCCESS;
89 }