* INTC Contribution to the O-RAN F Release for O-DU Low
[o-du/phy.git] / fapi_5g / source / api / fapi2mac / nr5g_fapi_fapi2mac_api.c
index 9af8822..cc7bf1c 100644 (file)
@@ -1,6 +1,6 @@
 /******************************************************************************
 *
-*   Copyright (c) 2019 Intel.
+*   Copyright (c) 2021 Intel.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 
 #include <stdio.h>
 #include "nr5g_fapi_internal.h"
-#include "gnb_l1_l2_api.h"
 #include "nr5g_fapi_fapi2mac_api.h"
 #include "nr5g_fapi_fapi2mac_wls.h"
 #include "nr5g_fapi_log.h"
 
 static nr5g_fapi_fapi2mac_queue_t fapi2mac_q[FAPI_MAX_PHY_INSTANCES];
+static nr5g_fapi_fapi2mac_queue_t fapi2mac_urllc_q[FAPI_MAX_PHY_INSTANCES];
+
 
 //------------------------------------------------------------------------------
 /** @ingroup     group_source_api_fapi2phy
  *
- *  @param[in]   p_list_elem Pointer to the ListElement
+ *  @param[in]   phy_id Value of phy_id.
+ *  @param[in]   is_urllc True for urllc, false otherwise.
  *
- *  @return      void
+ *  @return      Pointer to fapi2mac api queue.
  *
- *  @description This function adds a ListElement API to a Linked list which will
- *               be sent to L1 once all APIs for a TTI are added
+ *  @description This function access proper instance of fapi2mac queue.
  *
 **/
 //------------------------------------------------------------------------------
 static inline p_nr5g_fapi_fapi2mac_queue_t nr5g_fapi_fapi2mac_queue(
-    uint8_t phy_id)
+    uint8_t phy_id,
+    bool is_urllc)
 {
-    return &fapi2mac_q[phy_id];
+    return is_urllc ? &fapi2mac_urllc_q[phy_id] : &fapi2mac_q[phy_id];
 }
 
 //------------------------------------------------------------------------------
@@ -63,7 +65,8 @@ static inline p_nr5g_fapi_fapi2mac_queue_t nr5g_fapi_fapi2mac_queue(
 //------------------------------------------------------------------------------
 void nr5g_fapi_fapi2mac_add_api_to_list(
     uint8_t phy_id,
-    p_fapi_api_queue_elem_t p_list_elem)
+    p_fapi_api_queue_elem_t p_list_elem,
+    bool is_urllc)
 {
     p_nr5g_fapi_fapi2mac_queue_t queue = NULL;
     p_fapi_msg_header_t p_fapi_msg_hdr = NULL;
@@ -72,7 +75,7 @@ void nr5g_fapi_fapi2mac_add_api_to_list(
         return;
     }
 
-    queue = nr5g_fapi_fapi2mac_queue(phy_id);
+    queue = nr5g_fapi_fapi2mac_queue(phy_id, is_urllc);
     if (pthread_mutex_lock((pthread_mutex_t *) & queue->lock)) {
         NR5G_FAPI_LOG(ERROR_LOG, ("unable to lock fapi2mac aggregate list"
                 "pthread mutex"));
@@ -105,7 +108,7 @@ void nr5g_fapi_fapi2mac_add_api_to_list(
 **/
 //------------------------------------------------------------------------------
 void nr5g_fapi_fapi2mac_send_api_list(
-    )
+    bool is_urllc)
 {
     uint8_t phy_id = 0;
     p_fapi_msg_header_t p_fapi_msg_hdr = NULL;
@@ -114,7 +117,7 @@ void nr5g_fapi_fapi2mac_send_api_list(
     p_nr5g_fapi_fapi2mac_queue_t queue = NULL;
 
     for (phy_id = 0; phy_id < FAPI_MAX_PHY_INSTANCES; phy_id++) {
-        queue = nr5g_fapi_fapi2mac_queue(phy_id);
+        queue = nr5g_fapi_fapi2mac_queue(phy_id, is_urllc);
         if (pthread_mutex_lock((pthread_mutex_t *) & queue->lock)) {
             NR5G_FAPI_LOG(ERROR_LOG, ("unable to lock fapi2mac aggregate list"
                     "pthread mutex"));
@@ -145,7 +148,7 @@ void nr5g_fapi_fapi2mac_send_api_list(
     }
 
     if (p_commit_list_head)
-        nr5g_fapi_fapi2mac_wls_send(p_commit_list_head);
+        nr5g_fapi_fapi2mac_wls_send(p_commit_list_head, is_urllc);
 }
 
 //------------------------------------------------------------------------------
@@ -203,7 +206,9 @@ void nr5g_fapi_fapi2mac_init_api_list(
     p_nr5g_fapi_fapi2mac_queue_t queue = NULL;
 
     for (phy_id = 0; phy_id < FAPI_MAX_PHY_INSTANCES; phy_id++) {
-        queue = nr5g_fapi_fapi2mac_queue(phy_id);
+        queue = nr5g_fapi_fapi2mac_queue(phy_id, false);
+        pthread_mutex_init((pthread_mutex_t *) & queue->lock, NULL);
+        queue = nr5g_fapi_fapi2mac_queue(phy_id, true);
         pthread_mutex_init((pthread_mutex_t *) & queue->lock, NULL);
     }
 }