FAPI TM, WLS_LIB and ODULOW documentation
[o-du/phy.git] / fapi_5g / source / api / fapi2phy / p5 / nr5g_fapi_proc_dl_iq_samples_req.c
diff --git a/fapi_5g/source/api/fapi2phy/p5/nr5g_fapi_proc_dl_iq_samples_req.c b/fapi_5g/source/api/fapi2phy/p5/nr5g_fapi_proc_dl_iq_samples_req.c
new file mode 100644 (file)
index 0000000..c6b3b35
--- /dev/null
@@ -0,0 +1,130 @@
+/******************************************************************************
+*
+*   Copyright (c) 2019 Intel.
+*
+*   Licensed under the Apache License, Version 2.0 (the "License");
+*   you may not use this file except in compliance with the License.
+*   You may obtain a copy of the License at
+*
+*       http://www.apache.org/licenses/LICENSE-2.0
+*
+*   Unless required by applicable law or agreed to in writing, software
+*   distributed under the License is distributed on an "AS IS" BASIS,
+*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*   See the License for the specific language governing permissions and
+*   limitations under the License.
+*
+*******************************************************************************/
+/**
+ * @file
+ * This file consist of implementation of FAPI DLIQSamples.request message.
+ *
+ **/
+#include "nr5g_fapi_framework.h"
+#include "gnb_l1_l2_api.h"
+#include "nr5g_fapi_fapi2mac_api.h"
+#include "nr5g_fapi_fapi2phy_api.h"
+#include "nr5g_fapi_fapi2phy_p5_proc.h"
+#include "nr5g_fapi_fapi2phy_p5_pvt_proc.h"
+#include "nr5g_fapi_memory.h"
+
+ /** @ingroup group_source_api_p5_fapi2phy_proc
+ *
+ *  @param[in]  p_fapi_req Pointer to FAPI DLIQSamples.request message structure.
+ *  @return     Returns ::SUCCESS and ::FAILURE.
+ *
+ *  @description
+ *  This is a timer mode specific message used to transmit IQ Sample API to L1.
+ *  In DL direction, L1 copies the IQ samples into a file. 
+ *
+ *
+**/
+#ifdef DEBUG_MODE
+uint8_t nr5g_fapi_dl_iq_samples_request(
+    fapi_vendor_ext_iq_samples_req_t * p_fapi_req)
+{
+    uint16_t num_ant;
+
+    fapi_vendor_ext_iq_samples_info_t *p_file_info;
+    PMAC2PHY_QUEUE_EL p_list_elem;
+
+    if (NULL == p_fapi_req) {
+        NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_Samples.request] Invalid FAPI "
+                "message"));
+        return FAILURE;
+    }
+
+    p_list_elem = nr5g_fapi_fapi2phy_create_api_list_elem((uint8_t)
+        MSG_TYPE_PHY_DL_IQ_SAMPLES, 1,
+        (uint32_t) sizeof(fapi_vendor_ext_iq_samples_info_t));
+    if (!p_list_elem) {
+        NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_Samples.request] Unable to create "
+                "list element. Out of memory!!!"));
+        return FAILURE;
+    }
+
+    p_file_info = (fapi_vendor_ext_iq_samples_info_t *) (p_list_elem + 1);
+    p_file_info->carrNum = p_fapi_req->iq_samples_info.carrNum;
+    p_file_info->numSubframes = p_fapi_req->iq_samples_info.numSubframes;
+    p_file_info->testUeMode = p_fapi_req->iq_samples_info.testUeMode;
+    p_file_info->timerModeFreqDomain =
+        p_fapi_req->iq_samples_info.timerModeFreqDomain;
+    p_file_info->phaseCompensationEnable =
+        p_fapi_req->iq_samples_info.phaseCompensationEnable;
+    p_file_info->startFrameNum = p_fapi_req->iq_samples_info.startFrameNum;
+    p_file_info->startSlotNum = p_fapi_req->iq_samples_info.startSlotNum;
+    if (FAILURE == NR5G_FAPI_MEMCPY(p_file_info->buffer,
+            sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_BUFFER_SIZE,
+            p_fapi_req->iq_samples_info.buffer, sizeof(CONFIGREQUESTStruct))) {
+        NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_Samples.request] Buffer copy "
+                "failed!!!"));
+    }
+
+    if (FAILURE == NR5G_FAPI_STRCPY(p_file_info->filename_out_dl_iq,
+            sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE,
+            p_fapi_req->iq_samples_info.filename_out_dl_iq,
+            sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE)) {
+        NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_Samples.request] file name copy "
+                "failed!!!"));
+    }
+
+    if (FAILURE == NR5G_FAPI_STRCPY(p_file_info->filename_out_dl_iq_urllc,
+            sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE,
+            p_fapi_req->iq_samples_info.filename_out_dl_iq_urllc,
+            sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE)) {
+        NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_Samples.request] URLLC file name "
+                "copy failed!!!"));
+    }
+
+    for (num_ant = 0; num_ant < FAPI_MAX_IQ_SAMPLE_DL_PORTS; num_ant++) {
+        if (FAILURE ==
+            NR5G_FAPI_STRCPY(p_file_info->filename_out_dl_beam[num_ant],
+                sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE,
+                p_fapi_req->iq_samples_info.filename_out_dl_beam[num_ant],
+                sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE)) {
+
+            NR5G_FAPI_LOG(ERROR_LOG, ("[DL_IQ_Samples.request] DL Beam "
+                    "file name copy failed!!!"));
+        }
+    }
+
+    for (num_ant = 0; num_ant < FAPI_MAX_IQ_SAMPLE_UL_VIRTUAL_PORTS; num_ant++) {
+        if (FAILURE ==
+            NR5G_FAPI_STRCPY(p_file_info->filename_out_ul_beam[num_ant],
+                sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE,
+                p_fapi_req->iq_samples_info.filename_out_ul_beam[num_ant],
+                sizeof(uint8_t) * FAPI_MAX_IQ_SAMPLE_FILE_SIZE)) {
+            NR5G_FAPI_LOG(ERROR_LOG,
+                ("[DL_IQ_Samples.request] UL Beam "
+                    "file name copy failed!!!"));
+        }
+    }
+
+    nr5g_fapi_fapi2phy_add_to_api_list(p_list_elem);
+
+    NR5G_FAPI_LOG(INFO_LOG, ("[DL_IQ_Samples.request][%d]",
+            p_fapi_req->iq_samples_info.carrNum));
+
+    return SUCCESS;
+}
+#endif