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 START.request 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_fapi2phy_api.h"
29 #include "nr5g_fapi_fapi2phy_p5_proc.h"
30 #include "nr5g_fapi_fapi2phy_p5_pvt_proc.h"
32 /** @ingroup group_source_api_p5_fapi2phy_proc
34 * @param[in] p_phy_instance Pointer to PHY instance.
35 * @param[in] p_fapi_req Pointer to FAPI START.request message structure.
36 * @param[in] p_fapi_vendor_msg Pointer to FAPI vendor message structure.
37 * @return Returns ::SUCCESS and ::FAILURE.
40 * This message instructs a configured PHY to start transmitting as an eNB. If
41 * the PHY is in the CONFIGURED state, it will issue SLOT indication.
42 * After the PHY has sent its first SLOT.indication message it enters the
43 * RUNNING state. If the PHY receives a START.request in either the IDLE or
44 * RUNNING state it will return an ERROR.indication including an INVALID_STATE
47 * The *nSFN*, *nSlot*, and *nCarrierIdx* parameters are vendor specific
48 * configuration and programmed through Vendor Specific Message structure
49 * ::fapi_start_req_vendor_msg_t
51 * The *phyMode*, *ttiPeriod*, and *numSubframes* parameters of Vendor Specific
52 * Message structure ::fapi_start_req_vendor_msg_t are applicable only for
53 * TIMER mode (used for debugging only).
56 uint8_t nr5g_fapi_start_request(
57 p_nr5g_fapi_phy_instance_t p_phy_instance,
58 fapi_start_req_t * p_fapi_req,
59 fapi_vendor_msg_t * p_fapi_vendor_msg)
61 PSTARTREQUESTStruct p_start_req;
62 PMAC2PHY_QUEUE_EL p_list_elem;
63 nr5g_fapi_stats_t *p_stats;
65 if (NULL == p_phy_instance) {
66 NR5G_FAPI_LOG(ERROR_LOG, ("[START.request] Invalid " "phy instance"));
69 p_stats = &p_phy_instance->stats;
70 p_stats->fapi_stats.fapi_start_req++;
72 if (FAPI_STATE_CONFIGURED != p_phy_instance->state) {
73 // TODO: Return Error indication to mac
74 // // Please refer PHY State transition.
75 NR5G_FAPI_LOG(ERROR_LOG, ("[START.request] Received in "
76 "other than CONFIGURED State"));
80 if (NULL == p_fapi_req) {
81 NR5G_FAPI_LOG(ERROR_LOG, ("[START.request] Invalid fapi " "message"));
85 if (NULL == p_fapi_vendor_msg) {
86 NR5G_FAPI_LOG(ERROR_LOG, ("[START.request] Invalid fapi "
91 if (p_fapi_vendor_msg->start_req_vendor.mode > 4) {
92 NR5G_FAPI_LOG(ERROR_LOG, ("[START.request] PHY Mode %u invalid",
93 p_fapi_vendor_msg->start_req_vendor.mode));
97 p_list_elem = nr5g_fapi_fapi2phy_create_api_list_elem((uint8_t)
98 MSG_TYPE_PHY_START_REQ, 1, (uint32_t) sizeof(STARTREQUESTStruct));
100 NR5G_FAPI_LOG(ERROR_LOG, (" [START.request] Unable to create "
101 "list element. Out of memory!!!"));
105 p_start_req = (PSTARTREQUESTStruct) (p_list_elem + 1);
106 p_start_req->sMsgHdr.nMessageType = MSG_TYPE_PHY_START_REQ;
107 p_start_req->sMsgHdr.nMessageLen = (uint16_t) sizeof(STARTREQUESTStruct);
108 p_start_req->sSFN_Slot.nSFN = p_fapi_vendor_msg->start_req_vendor.sfn;
109 p_start_req->sSFN_Slot.nSlot = p_fapi_vendor_msg->start_req_vendor.slot;
110 p_start_req->sSFN_Slot.nCarrierIdx = p_phy_instance->phy_id;
111 p_start_req->nMode = p_fapi_vendor_msg->start_req_vendor.mode;
113 /* Setting period and count only for timer mode */
114 if (1 == p_fapi_vendor_msg->start_req_vendor.mode) {
115 p_start_req->nCount = p_fapi_vendor_msg->start_req_vendor.count;
116 p_start_req->nPeriod = p_fapi_vendor_msg->start_req_vendor.period;
120 /* Add element to send list */
121 nr5g_fapi_fapi2phy_add_to_api_list(p_list_elem);
123 p_stats->iapi_stats.iapi_start_req++;
124 NR5G_FAPI_LOG(INFO_LOG, ("[START.request][%d]", p_phy_instance->phy_id));