O-RAN E Maintenance Release contribution for ODULOW
[o-du/phy.git] / fapi_5g / source / api / fapi2mac / p7 / nr5g_fapi_proc_srs_ind.c
index 84f963d..b9310ec 100644 (file)
@@ -27,6 +27,7 @@
 #include "nr5g_fapi_fapi2mac_api.h"
 #include "nr5g_fapi_fapi2mac_p7_proc.h"
 #include "nr5g_fapi_fapi2mac_p7_pvt_proc.h"
+#include "nr5g_fapi_memory.h"
 
  /** @ingroup group_source_api_p7_fapi2mac_proc
  *
@@ -40,7 +41,9 @@
  *
 **/
 uint8_t nr5g_fapi_srs_indication(
+    bool is_urllc,
     p_nr5g_fapi_phy_ctx_t p_phy_ctx,
+    p_fapi_api_stored_vendor_queue_elems vendor_extension_elems,
     PRXSRSIndicationStruct p_phy_srs_ind)
 {
     uint8_t phy_id;
@@ -48,6 +51,8 @@ uint8_t nr5g_fapi_srs_indication(
     p_fapi_api_queue_elem_t p_list_elem;
     p_nr5g_fapi_phy_instance_t p_phy_instance = NULL;
     nr5g_fapi_stats_t *p_stats;
+    fapi_vendor_p7_ind_msg_t *p_fapi_vend_p7;
+    fapi_vendor_ext_srs_ind_t *p_fapi_vend_srs_ind;
 
     if (NULL == p_phy_ctx) {
         NR5G_FAPI_LOG(ERROR_LOG, ("[SRS.indication] Invalid " "Phy Context"));
@@ -83,20 +88,25 @@ uint8_t nr5g_fapi_srs_indication(
     p_fapi_srs_ind->header.msg_id = FAPI_SRS_INDICATION;
     p_fapi_srs_ind->header.length = (uint16_t) sizeof(fapi_srs_indication_t);
 
-    if (nr5g_fapi_srs_indication_to_fapi_translation(p_phy_instance,
-            p_phy_srs_ind, p_fapi_srs_ind)) {
+    p_fapi_vend_p7 =
+        nr5g_fapi_proc_vendor_p7_msg_get(vendor_extension_elems, phy_id);
+    p_fapi_vend_srs_ind =
+        p_fapi_vend_p7 ? &p_fapi_vend_p7->srs_ind : NULL;
+    if (nr5g_fapi_srs_indication_to_fapi_translation(is_urllc, p_phy_instance,
+            p_phy_srs_ind, p_fapi_srs_ind, p_fapi_vend_srs_ind)) {
         NR5G_FAPI_LOG(ERROR_LOG,
             ("[SRS.indication] L1 to FAPI " "translation failed"));
         return FAILURE;
     }
 
     /* Add element to send list */
-    nr5g_fapi_fapi2mac_add_api_to_list(phy_id, p_list_elem);
+    nr5g_fapi_fapi2mac_add_api_to_list(phy_id, p_list_elem, is_urllc);
 
     p_stats->fapi_stats.fapi_srs_ind++;
-    NR5G_FAPI_LOG(DEBUG_LOG, ("[SRS.indication][%d][%d,%d]",
+    NR5G_FAPI_LOG(DEBUG_LOG, ("[SRS.indication][%u][%u,%u,%u] is_urllc %u",
             p_phy_instance->phy_id,
-            p_phy_srs_ind->sSFN_Slot.nSFN, p_phy_srs_ind->sSFN_Slot.nSlot));
+            p_phy_srs_ind->sSFN_Slot.nSFN, p_phy_srs_ind->sSFN_Slot.nSlot,
+            p_phy_srs_ind->sSFN_Slot.nSym, is_urllc));
 
     return SUCCESS;
 }
@@ -147,15 +157,17 @@ nr5g_fapi_srs_info_t *nr5g_fapi_get_srs_info(
  *
 **/
 uint8_t nr5g_fapi_srs_indication_to_fapi_translation(
+    bool is_urllc,
     p_nr5g_fapi_phy_instance_t p_phy_instance,
     PRXSRSIndicationStruct p_phy_srs_ind,
-    fapi_srs_indication_t * p_fapi_srs_ind)
+    fapi_srs_indication_t * p_fapi_srs_ind,
+    fapi_vendor_ext_srs_ind_t * p_fapi_vend_srs_ind)
 {
     uint8_t num_srs_pdus, i;
-    uint8_t slot_no, num_rept_symbols, nr_of_symbols;
-    uint16_t frame_no, num_rbs, j, k;
+    uint8_t symbol_no, num_rept_symbols, nr_of_symbols;
+    uint16_t slot_no, frame_no, num_rbs, j, k;
     int8_t wideband_snr = 0, rb_snr;
-    int16_t temp = 0;
+    int16_t temp_sum_wideband_snr;
 
     nr5g_fapi_srs_info_t *p_srs_info;
     fapi_srs_pdu_t *p_fapi_srs_pdu;
@@ -163,14 +175,16 @@ uint8_t nr5g_fapi_srs_indication_to_fapi_translation(
     nr5g_fapi_ul_slot_info_t *p_ul_slot_info;
     nr5g_fapi_stats_t *p_stats;
     ULSRSEstStruct *p_ul_srs_est_struct;
+    fapi_vendor_ext_srs_pdu_t *p_vend_srs_pdu;
 
     p_stats = &p_phy_instance->stats;
 
     frame_no = p_fapi_srs_ind->sfn = p_phy_srs_ind->sSFN_Slot.nSFN;
     slot_no = p_fapi_srs_ind->slot = p_phy_srs_ind->sSFN_Slot.nSlot;
+    symbol_no = p_phy_srs_ind->sSFN_Slot.nSym;
 
     p_ul_slot_info =
-        nr5g_fapi_get_ul_slot_info(frame_no, slot_no, p_phy_instance);
+        nr5g_fapi_get_ul_slot_info(is_urllc, frame_no, slot_no, symbol_no, p_phy_instance);
 
     if (p_ul_slot_info == NULL) {
         NR5G_FAPI_LOG(ERROR_LOG, ("[SRS.indication] No Valid data available "
@@ -180,6 +194,7 @@ uint8_t nr5g_fapi_srs_indication_to_fapi_translation(
 
     num_srs_pdus = p_fapi_srs_ind->numPdus = p_phy_srs_ind->nNrOfSrs;
     for (i = 0; i < num_srs_pdus; i++) {
+        temp_sum_wideband_snr = 0;
         p_stats->iapi_stats.iapi_srs_ind_pdus++;
         p_fapi_srs_pdu = &p_fapi_srs_ind->srsPdus[i];
         p_ul_srs_est_struct = &p_phy_srs_ind->sULSRSEstStruct[i];
@@ -200,9 +215,9 @@ uint8_t nr5g_fapi_srs_indication_to_fapi_translation(
         nr_of_symbols = p_fapi_srs_pdu->numSymbols =
             p_ul_srs_est_struct->nNrOfSymbols;
         for (j = 0; j < nr_of_symbols; j++) {
-            temp += p_ul_srs_est_struct->nWideBandSNR[j];
+            temp_sum_wideband_snr += p_ul_srs_est_struct->nWideBandSNR[j];
         }
-        wideband_snr = temp / nr_of_symbols;
+        wideband_snr = temp_sum_wideband_snr / nr_of_symbols;
 
         p_fapi_srs_pdu->wideBandSnr = (wideband_snr + 64) * 2;
         num_rept_symbols = p_fapi_srs_pdu->numReportedSymbols = 1;
@@ -218,6 +233,20 @@ uint8_t nr5g_fapi_srs_indication_to_fapi_translation(
             }
         }
         p_stats->fapi_stats.fapi_srs_ind_pdus++;
+
+        if(p_fapi_vend_srs_ind) { // Fill vendor ext
+            p_fapi_vend_srs_ind->num_pdus = p_phy_srs_ind->nNrOfSrs;
+            p_vend_srs_pdu = &p_fapi_vend_srs_ind->srs_pdus[i];
+            p_vend_srs_pdu->nr_of_port = p_ul_srs_est_struct->nNrOfPort;
+            p_vend_srs_pdu->nr_of_rx_ant = p_ul_srs_est_struct->nNrOfRxAnt;
+            p_vend_srs_pdu->nr_of_rbs = p_ul_srs_est_struct->nNrOfRbs;
+            p_vend_srs_pdu->is_chan_est_pres =
+                p_ul_srs_est_struct->nIsChanEstPres;
+            NR5G_FAPI_MEMCPY(p_vend_srs_pdu->p_srs_chan_est,
+                sizeof(p_vend_srs_pdu->p_srs_chan_est),
+                p_ul_srs_est_struct->pSrsChanEst,
+                sizeof(p_ul_srs_est_struct->pSrsChanEst));
+        }
     }
 
     return SUCCESS;