X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=fapi_5g%2Fsource%2Fapi%2Ffapi2mac%2Fnr5g_fapi_fapi2mac_api.c;h=cc7bf1cd2d1935cd34619ab5279e09b81a37df4a;hb=HEAD;hp=9ac28927375d6da785e76b4c7adcb8b63a6b8d5d;hpb=9d66fca5c45c8b3e0d6eab6d51a90c8e9d2614dc;p=o-du%2Fphy.git diff --git a/fapi_5g/source/api/fapi2mac/nr5g_fapi_fapi2mac_api.c b/fapi_5g/source/api/fapi2mac/nr5g_fapi_fapi2mac_api.c index 9ac2892..cc7bf1c 100644 --- a/fapi_5g/source/api/fapi2mac/nr5g_fapi_fapi2mac_api.c +++ b/fapi_5g/source/api/fapi2mac/nr5g_fapi_fapi2mac_api.c @@ -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. @@ -24,28 +24,31 @@ #include #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. * **/ //------------------------------------------------------------------------------ -inline p_nr5g_fapi_fapi2mac_queue_t nr5g_fapi_fapi2mac_queue( - uint8_t phy_id) +static inline p_nr5g_fapi_fapi2mac_queue_t nr5g_fapi_fapi2mac_queue( + uint8_t phy_id, + bool is_urllc) { - return &fapi2mac_q[phy_id]; + return is_urllc ? &fapi2mac_urllc_q[phy_id] : &fapi2mac_q[phy_id]; } //------------------------------------------------------------------------------ @@ -62,7 +65,8 @@ 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; @@ -71,7 +75,12 @@ 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")); + return; + } if (queue->p_send_list_head && queue->p_send_list_tail) { p_fapi_msg_hdr = (p_fapi_msg_header_t) (queue->p_send_list_head + 1); p_fapi_msg_hdr->num_msg += 1; @@ -80,6 +89,11 @@ void nr5g_fapi_fapi2mac_add_api_to_list( } else { queue->p_send_list_head = queue->p_send_list_tail = p_list_elem; } + if (pthread_mutex_unlock((pthread_mutex_t *) & queue->lock)) { + NR5G_FAPI_LOG(ERROR_LOG, ("unable to unlock fapi2mac aggregate list" + "pthread mutex")); + return; + } } //------------------------------------------------------------------------------ @@ -94,29 +108,47 @@ 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; p_fapi_api_queue_elem_t p_commit_list_head = NULL; p_fapi_api_queue_elem_t p_commit_list_tail = NULL; 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")); + return; + } if (queue->p_send_list_head && queue->p_send_list_tail) { - if (p_commit_list_head && p_commit_list_tail) { - p_commit_list_tail->p_next = queue->p_send_list_head; - p_commit_list_tail = queue->p_send_list_tail; + p_fapi_msg_hdr = + (p_fapi_msg_header_t) (queue->p_send_list_head + 1); + if (p_fapi_msg_hdr->num_msg) { + if (p_commit_list_head && p_commit_list_tail) { + p_commit_list_tail->p_next = queue->p_send_list_head; + p_commit_list_tail = queue->p_send_list_tail; + } else { + p_commit_list_head = queue->p_send_list_head; + p_commit_list_tail = queue->p_send_list_tail; + } } else { - p_commit_list_head = queue->p_send_list_head; - p_commit_list_tail = queue->p_send_list_tail; + nr5g_fapi_fapi2mac_wls_free_buffer((void *) + queue->p_send_list_head); } queue->p_send_list_head = queue->p_send_list_tail = NULL; } + if (pthread_mutex_unlock((pthread_mutex_t *) & queue->lock)) { + NR5G_FAPI_LOG(ERROR_LOG, ("unable to unlock fapi2mac aggregate list" + "pthread mutex")); + return; + } } 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); } //------------------------------------------------------------------------------ @@ -160,3 +192,23 @@ p_fapi_api_queue_elem_t nr5g_fapi_fapi2mac_create_api_list_elem( return p_list_elem; } +//------------------------------------------------------------------------------ +/** @ingroup group_lte_source_phy_fapi + * + * @return void + * + * @description This function initializes the pthead_mutext_lock. + */ +void nr5g_fapi_fapi2mac_init_api_list( + ) +{ + uint8_t phy_id = 0; + 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, 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); + } +}