X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=components%2Fbt%2Fbluedroid%2Fstack%2Frfcomm%2Fport_utils.c;h=0da8b3d76b7318dd176b025d9f0e206db18ca7d1;hb=4f227a4ce39265a39ab9c900763ada3fac7338ab;hp=5b2e79178f166062a4955390340df9d61220fc74;hpb=9a774848d431be37c3eed46bff2ab3bd185eaec3;p=esp-idf diff --git a/components/bt/bluedroid/stack/rfcomm/port_utils.c b/components/bt/bluedroid/stack/rfcomm/port_utils.c index 5b2e79178f..0da8b3d76b 100644 --- a/components/bt/bluedroid/stack/rfcomm/port_utils.c +++ b/components/bt/bluedroid/stack/rfcomm/port_utils.c @@ -23,15 +23,17 @@ ******************************************************************************/ #include -#include "bt_target.h" -#include "gki.h" -#include "rfcdefs.h" -#include "port_api.h" +#include "common/bt_target.h" +#include "stack/rfcdefs.h" +#include "stack/port_api.h" #include "port_int.h" #include "rfc_int.h" -#include "l2cdefs.h" +#include "stack/l2cdefs.h" #include "btm_int.h" -#include "btu.h" +#include "stack/btu.h" +#include "osi/mutex.h" +#include "osi/allocator.h" +#if (defined RFCOMM_INCLUDED && RFCOMM_INCLUDED == TRUE) static const tPORT_STATE default_port_pars = { PORT_BAUD_RATE_9600, @@ -125,6 +127,9 @@ void port_set_defaults (tPORT *p_port) memset (&p_port->peer_ctrl, 0, sizeof (p_port->peer_ctrl)); memset (&p_port->rx, 0, sizeof (p_port->rx)); memset (&p_port->tx, 0, sizeof (p_port->tx)); + + p_port->tx.queue = fixed_queue_new(QUEUE_SIZE_MAX); + p_port->rx.queue = fixed_queue_new(QUEUE_SIZE_MAX); } /******************************************************************************* @@ -203,21 +208,21 @@ void port_release_port (tPORT *p_port) tPORT_CALLBACK *p_port_cb; tPORT_STATE user_port_pars; - PORT_SCHEDULE_LOCK; + osi_mutex_global_lock(); RFCOMM_TRACE_DEBUG("port_release_port, p_port:%p", p_port); - while ((p_buf = (BT_HDR *)GKI_dequeue (&p_port->rx.queue)) != NULL) { - GKI_freebuf (p_buf); + while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_port->rx.queue)) != NULL) { + osi_free (p_buf); } p_port->rx.queue_size = 0; - while ((p_buf = (BT_HDR *)GKI_dequeue (&p_port->tx.queue)) != NULL) { - GKI_freebuf (p_buf); + while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_port->tx.queue)) != NULL) { + osi_free (p_buf); } p_port->tx.queue_size = 0; - PORT_SCHEDULE_UNLOCK; + osi_mutex_global_unlock(); p_port->state = PORT_STATE_CLOSED; @@ -230,6 +235,11 @@ void port_release_port (tPORT *p_port) rfc_check_mcb_active (p_port->rfc.p_mcb); } rfc_port_timer_stop (p_port); + fixed_queue_free(p_port->tx.queue, NULL); + p_port->tx.queue = NULL; + fixed_queue_free(p_port->rx.queue, NULL); + p_port->rx.queue = NULL; + RFCOMM_TRACE_DEBUG ("port_release_port:p_port->keep_port_handle:%d", p_port->keep_port_handle); if ( p_port->keep_port_handle ) { RFCOMM_TRACE_DEBUG ("port_release_port:Initialize handle:%d", p_port->inx); @@ -255,6 +265,7 @@ void port_release_port (tPORT *p_port) memcpy (p_port->bd_addr, BT_BD_ANY, BD_ADDR_LEN); } else { RFCOMM_TRACE_DEBUG ("port_release_port:Clean-up handle:%d", p_port->inx); + rfc_port_timer_free (p_port); memset (p_port, 0, sizeof (tPORT)); } } @@ -402,7 +413,7 @@ UINT32 port_flow_control_user (tPORT *p_port) || !p_port->rfc.p_mcb || !p_port->rfc.p_mcb->peer_ready || (p_port->tx.queue_size > PORT_TX_HIGH_WM) - || (GKI_queue_length(&p_port->tx.queue) > PORT_TX_BUF_HIGH_WM); + || (fixed_queue_length(p_port->tx.queue) > PORT_TX_BUF_HIGH_WM); if (p_port->tx.user_fc == fc) { return (0); @@ -514,7 +525,7 @@ void port_flow_control_peer(tPORT *p_port, BOOLEAN enable, UINT16 count) p_port->rx.peer_fc = TRUE; } /* if queue count reached credit rx max, set peer fc */ - else if (GKI_queue_length(&p_port->rx.queue) >= p_port->credit_rx_max) { + else if (fixed_queue_length(p_port->rx.queue) >= p_port->credit_rx_max) { p_port->rx.peer_fc = TRUE; } } @@ -527,7 +538,7 @@ void port_flow_control_peer(tPORT *p_port, BOOLEAN enable, UINT16 count) /* check if it can be resumed now */ if (p_port->rx.peer_fc && (p_port->rx.queue_size < PORT_RX_LOW_WM) - && (GKI_queue_length(&p_port->rx.queue) < PORT_RX_BUF_LOW_WM)) { + && (fixed_queue_length(p_port->rx.queue) < PORT_RX_BUF_LOW_WM)) { p_port->rx.peer_fc = FALSE; /* If user did not force flow control allow traffic now */ @@ -546,7 +557,7 @@ void port_flow_control_peer(tPORT *p_port, BOOLEAN enable, UINT16 count) /* Check the size of the rx queue. If it exceeds certain */ /* level and flow control has not been sent to the peer do it now */ else if ( ((p_port->rx.queue_size > PORT_RX_HIGH_WM) - || (GKI_queue_length(&p_port->rx.queue) > PORT_RX_BUF_HIGH_WM)) + || (fixed_queue_length(p_port->rx.queue) > PORT_RX_BUF_HIGH_WM)) && !p_port->rx.peer_fc) { RFCOMM_TRACE_EVENT ("PORT_DataInd Data reached HW. Sending FC set."); @@ -557,3 +568,5 @@ void port_flow_control_peer(tPORT *p_port, BOOLEAN enable, UINT16 count) } } + +#endif ///(defined RFCOMM_INCLUDED && RFCOMM_INCLUDED == TRUE)