* INTC Contribution to the O-RAN F Release for O-DU Low
[o-du/phy.git] / fapi_5g / source / framework / wls / fapi2mac / nr5g_fapi_fapi2mac_wls.c
index f2277e7..ce4b86d 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 "nr5g_fapi_std.h"
 #include "nr5g_fapi_common_types.h"
 #include "nr5g_fapi_wls.h"
-#include "gnb_l1_l2_api.h"
 #include "nr5g_fapi_fapi2mac_wls.h"
 #include "nr5g_fapi_log.h"
+#include "nr5g_fapi_framework.h"
 
 static p_fapi_api_queue_elem_t p_fapi2mac_buffers;
 
+uint64_t *nr5g_fapi_fapi2mac_wls_get(
+    uint32_t * const msg_size,
+    uint16_t * const msg_type,
+    uint16_t * const flags);
+
+uint8_t nr5g_fapi_fapi2mac_wls_put(
+    const p_fapi_api_queue_elem_t p_msg,
+    uint32_t msg_size,
+    uint16_t msg_type,
+    uint16_t flags);
+
+uint8_t nr5g_fapi_fapi2mac_wls_send(
+    const p_fapi_api_queue_elem_t p_list_elem,
+    bool is_urllc);
+
 //------------------------------------------------------------------------------
 /** @ingroup nr5g_fapi_source_framework_wls_fapi2mac_group
  *
@@ -171,7 +186,7 @@ void nr5g_fapi_fapi2mac_wls_free_buffer(
  *  @return  0 if SUCCESS
  *
  *  @description
- *  This function is called at WLS init and waits in an infinite for L1 to respond back with some information
+ *  This function is called at WLS init and waits infinitely for L1 to respond back with some information
  *  needed by the L2
  *
 **/
@@ -192,12 +207,12 @@ uint8_t nr5g_fapi_fapi2mac_wls_ready(
  *  @return  Number of blocks of APIs received
  *
  *  @description
- *  This functions waits in a infinite loop for L1 to send a list of APIs to MAC. This is called
- *  during runtime when L2 sends a API to L1 and then waits for response back.
+ *  This functions waits in an infinite loop for L1 to send a list of APIs to MAC. This is called
+ *  during runtime when L2 sends API to L1 and then waits for a response back.
  *
 **/
 //------------------------------------------------------------------------------
-uint8_t nr5g_fapi_fapi2mac_wls_wait(
+uint32_t nr5g_fapi_fapi2mac_wls_wait(
     )
 {
     int ret = SUCCESS;
@@ -238,9 +253,9 @@ static inline uint8_t is_msg_present(
 **/
 //------------------------------------------------------------------------------
 uint64_t *nr5g_fapi_fapi2mac_wls_get(
-    uint32_t * msg_size,
-    uint16_t * msg_type,
-    uint16_t * flags)
+    uint32_t * const msg_size,
+    uint16_t * const msg_type,
+    uint16_t * const flags)
 {
     uint64_t *data = NULL;
     WLS_HANDLE h_wls;
@@ -270,7 +285,7 @@ uint64_t *nr5g_fapi_fapi2mac_wls_get(
 **/
 //------------------------------------------------------------------------------
 inline uint8_t nr5g_fapi_fapi2mac_wls_put(
-    p_fapi_api_queue_elem_t p_msg,
+    const p_fapi_api_queue_elem_t p_msg,
     uint32_t msg_size,
     uint16_t msg_type,
     uint16_t flags)
@@ -300,12 +315,14 @@ inline uint8_t nr5g_fapi_fapi2mac_wls_put(
 **/
 //------------------------------------------------------------------------------
 uint8_t nr5g_fapi_fapi2mac_wls_send(
-    p_fapi_api_queue_elem_t p_list_elem)
+    const p_fapi_api_queue_elem_t p_list_elem,
+    bool is_urllc)
 {
     uint8_t ret = SUCCESS;
     p_fapi_api_queue_elem_t p_curr_msg = NULL;
     fapi_msg_t *p_msg_header = NULL;
     uint16_t flags = 0;
+    uint16_t flags_urllc = (is_urllc ? WLS_TF_URLLC : 0);
     p_nr5g_fapi_wls_context_t p_wls_ctx = nr5g_fapi_wls_context();
     uint64_t start_tick = __rdtsc();
 
@@ -317,7 +334,7 @@ uint8_t nr5g_fapi_fapi2mac_wls_send(
     }
 
     if (p_curr_msg && p_curr_msg->p_next) {
-        flags = WLS_SG_FIRST;
+        flags = WLS_SG_FIRST | flags_urllc;
         if (p_curr_msg->msg_type == FAPI_VENDOR_MSG_HEADER_IND) {
             if (SUCCESS != nr5g_fapi_fapi2mac_wls_put(p_curr_msg,
                     p_curr_msg->msg_len + sizeof(fapi_api_queue_elem_t),
@@ -331,7 +348,7 @@ uint8_t nr5g_fapi_fapi2mac_wls_send(
                 return FAILURE;
             }
             p_curr_msg = p_curr_msg->p_next;
-            flags = WLS_SG_NEXT;
+            flags = WLS_SG_NEXT | flags_urllc;
         }
 
         while (p_curr_msg) {
@@ -351,7 +368,7 @@ uint8_t nr5g_fapi_fapi2mac_wls_send(
                 }
                 p_curr_msg = p_curr_msg->p_next;
             } else {            // LAST
-                flags = WLS_SG_LAST;
+                flags = WLS_SG_LAST | flags_urllc;
                 if (SUCCESS != nr5g_fapi_fapi2mac_wls_put(p_curr_msg,
                         p_curr_msg->msg_len + sizeof(fapi_api_queue_elem_t),
                         p_msg_header->msg_id, flags)) {
@@ -365,7 +382,7 @@ uint8_t nr5g_fapi_fapi2mac_wls_send(
                 }
                 p_curr_msg = NULL;
             }
-            flags = WLS_SG_NEXT;
+            flags = WLS_SG_NEXT | flags_urllc;
         }
     }
 
@@ -400,9 +417,9 @@ p_fapi_api_queue_elem_t nr5g_fapi_fapi2mac_wls_recv(
     uint32_t msg_size = 0;
     uint32_t num_elms = 0;
     uint64_t *p_msg = NULL;
-    p_fapi_api_queue_elem_t p_qelm_list = NULL;
+    p_fapi_api_queue_elem_t p_qelm_list = NULL, p_urllc_qelm_list = NULL;
     p_fapi_api_queue_elem_t p_qelm = NULL;
-    p_fapi_api_queue_elem_t p_tail_qelm = NULL;
+    p_fapi_api_queue_elem_t p_tail_qelm = NULL, p_urllc_tail_qelm = NULL;
     WLS_HANDLE h_wls = nr5g_fapi_fapi2mac_wls_instance();
     uint64_t start_tick = 0;
 
@@ -421,6 +438,19 @@ p_fapi_api_queue_elem_t nr5g_fapi_fapi2mac_wls_recv(
                 continue;
             }
             p_qelm->p_next = NULL;
+            
+            if (flags & WLS_TF_URLLC)
+            {
+                if (p_urllc_qelm_list) {
+                    p_urllc_tail_qelm = p_urllc_qelm_list;
+                    while (NULL != p_urllc_tail_qelm->p_next) {
+                        p_urllc_tail_qelm = p_urllc_tail_qelm->p_next;
+                    }
+                    p_urllc_tail_qelm->p_next = p_qelm;
+                } else {
+                    p_urllc_qelm_list = p_qelm;
+                }
+            } else {
             if (p_qelm_list) {
                 p_tail_qelm = p_qelm_list;
                 while (NULL != p_tail_qelm->p_next) {
@@ -431,8 +461,15 @@ p_fapi_api_queue_elem_t nr5g_fapi_fapi2mac_wls_recv(
                 p_qelm_list = p_qelm;
             }
         }
+        }
         num_elms--;
     } while (num_elms && is_msg_present(flags));
+
+    if (p_urllc_qelm_list) {
+        nr5g_fapi_urllc_thread_callback((void *) p_urllc_qelm_list,
+               &nr5g_fapi_get_nr5g_fapi_phy_ctx()->urllc_mac2phy_params);
+    }
+
     tick_total_wls_get_per_tti_dl += __rdtsc() - start_tick;
 
     return p_qelm_list;