c6b3b356d79c988defe48f2a6f565ef8c743b209
[o-du/phy.git] / fapi_5g / source / api / fapi2phy / p5 / nr5g_fapi_proc_dl_iq_samples_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  * @file
20  * This file consist of implementation of FAPI DLIQSamples.request message.
21  *
22  **/
23 #include "nr5g_fapi_framework.h"
24 #include "gnb_l1_l2_api.h"
25 #include "nr5g_fapi_fapi2mac_api.h"
26 #include "nr5g_fapi_fapi2phy_api.h"
27 #include "nr5g_fapi_fapi2phy_p5_proc.h"
28 #include "nr5g_fapi_fapi2phy_p5_pvt_proc.h"
29 #include "nr5g_fapi_memory.h"
30
31  /** @ingroup group_source_api_p5_fapi2phy_proc
32  *
33  *  @param[in]  p_fapi_req Pointer to FAPI DLIQSamples.request message structure.
34  *  @return     Returns ::SUCCESS and ::FAILURE.
35  *
36  *  @description
37  *  This is a timer mode specific message used to transmit IQ Sample API to L1.
38  *  In DL direction, L1 copies the IQ samples into a file. 
39  *
40  *
41 **/
42 #ifdef DEBUG_MODE
43 uint8_t nr5g_fapi_dl_iq_samples_request(
44     fapi_vendor_ext_iq_samples_req_t * p_fapi_req)
45 {
46     uint16_t num_ant;
47
48     fapi_vendor_ext_iq_samples_info_t *p_file_info;
49     PMAC2PHY_QUEUE_EL p_list_elem;
50
51     if (NULL == p_fapi_req) {
52         NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_Samples.request] Invalid FAPI "
53                 "message"));
54         return FAILURE;
55     }
56
57     p_list_elem = nr5g_fapi_fapi2phy_create_api_list_elem((uint8_t)
58         MSG_TYPE_PHY_DL_IQ_SAMPLES, 1,
59         (uint32_t) sizeof(fapi_vendor_ext_iq_samples_info_t));
60     if (!p_list_elem) {
61         NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_Samples.request] Unable to create "
62                 "list element. Out of memory!!!"));
63         return FAILURE;
64     }
65
66     p_file_info = (fapi_vendor_ext_iq_samples_info_t *) (p_list_elem + 1);
67     p_file_info->carrNum = p_fapi_req->iq_samples_info.carrNum;
68     p_file_info->numSubframes = p_fapi_req->iq_samples_info.numSubframes;
69     p_file_info->testUeMode = p_fapi_req->iq_samples_info.testUeMode;
70     p_file_info->timerModeFreqDomain =
71         p_fapi_req->iq_samples_info.timerModeFreqDomain;
72     p_file_info->phaseCompensationEnable =
73         p_fapi_req->iq_samples_info.phaseCompensationEnable;
74     p_file_info->startFrameNum = p_fapi_req->iq_samples_info.startFrameNum;
75     p_file_info->startSlotNum = p_fapi_req->iq_samples_info.startSlotNum;
76     if (FAILURE == NR5G_FAPI_MEMCPY(p_file_info->buffer,
77             sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_BUFFER_SIZE,
78             p_fapi_req->iq_samples_info.buffer, sizeof(CONFIGREQUESTStruct))) {
79         NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_Samples.request] Buffer copy "
80                 "failed!!!"));
81     }
82
83     if (FAILURE == NR5G_FAPI_STRCPY(p_file_info->filename_out_dl_iq,
84             sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE,
85             p_fapi_req->iq_samples_info.filename_out_dl_iq,
86             sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE)) {
87         NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_Samples.request] file name copy "
88                 "failed!!!"));
89     }
90
91     if (FAILURE == NR5G_FAPI_STRCPY(p_file_info->filename_out_dl_iq_urllc,
92             sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE,
93             p_fapi_req->iq_samples_info.filename_out_dl_iq_urllc,
94             sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE)) {
95         NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_Samples.request] URLLC file name "
96                 "copy failed!!!"));
97     }
98
99     for (num_ant = 0; num_ant < FAPI_MAX_IQ_SAMPLE_DL_PORTS; num_ant++) {
100         if (FAILURE ==
101             NR5G_FAPI_STRCPY(p_file_info->filename_out_dl_beam[num_ant],
102                 sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE,
103                 p_fapi_req->iq_samples_info.filename_out_dl_beam[num_ant],
104                 sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE)) {
105
106             NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_Samples.request] DL Beam "
107                     "file name copy failed!!!"));
108         }
109     }
110
111     for (num_ant = 0; num_ant < FAPI_MAX_IQ_SAMPLE_UL_VIRTUAL_PORTS; num_ant++) {
112         if (FAILURE ==
113             NR5G_FAPI_STRCPY(p_file_info->filename_out_ul_beam[num_ant],
114                 sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE,
115                 p_fapi_req->iq_samples_info.filename_out_ul_beam[num_ant],
116                 sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE)) {
117             NR5G_FAPI_LOG(ERROR_LOG,
118                 ("[DL_IQ_Samples.request] UL Beam "
119                     "file name copy failed!!!"));
120         }
121     }
122
123     nr5g_fapi_fapi2phy_add_to_api_list(p_list_elem);
124
125     NR5G_FAPI_LOG(INFO_LOG, ("[DL_IQ_Samples.request][%d]",
126             p_fapi_req->iq_samples_info.carrNum));
127
128     return SUCCESS;
129 }
130 #endif