From fe7216ca12f91baae733e7c93063db73121af308 Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Tue, 6 May 2014 10:35:42 -0700 Subject: Enforce GKI API buffer usage Also add another API GKI_queue_length(BUFFER_Q *) --- stack/l2cap/l2c_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'stack/l2cap/l2c_main.c') diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c index 325f7af8e..1b45713e0 100755 --- a/stack/l2cap/l2c_main.c +++ b/stack/l2cap/l2c_main.c @@ -152,11 +152,11 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) { L2CAP_TRACE_WARNING ("L2CAP - holding ACL for unknown handle:%d ls:%d cid:%d opcode:%d cur count:%d", handle, p_msg->layer_specific, rcv_cid, cmd_code, - l2cb.rcv_hold_q.count); + GKI_queue_length(&l2cb.rcv_hold_q)); p_msg->layer_specific = 2; GKI_enqueue (&l2cb.rcv_hold_q, p_msg); - if (l2cb.rcv_hold_q.count == 1) + if (GKI_queue_length(&l2cb.rcv_hold_q) == 1) btu_start_timer (&l2cb.rcv_hold_tle, BTU_TTYPE_L2CAP_HOLD, BT_1SEC_TIMEOUT); return; @@ -164,7 +164,7 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) else { L2CAP_TRACE_ERROR ("L2CAP - rcvd ACL for unknown handle:%d ls:%d cid:%d opcode:%d cur count:%d", - handle, p_msg->layer_specific, rcv_cid, cmd_code, l2cb.rcv_hold_q.count); + handle, p_msg->layer_specific, rcv_cid, cmd_code, GKI_queue_length(&l2cb.rcv_hold_q)); } GKI_freebuf (p_msg); return; @@ -816,7 +816,7 @@ void l2c_process_held_packets (BOOLEAN timed_out) BT_HDR *p_buf, *p_buf1; BUFFER_Q *p_rcv_hold_q = &l2cb.rcv_hold_q; - if (!p_rcv_hold_q->count) + if (GKI_queue_is_empty(p_rcv_hold_q)) return; if (!timed_out) @@ -842,7 +842,7 @@ void l2c_process_held_packets (BOOLEAN timed_out) } /* If anyone still in the queue, restart the timeout */ - if (p_rcv_hold_q->count) + if (!GKI_queue_is_empty(p_rcv_hold_q)) btu_start_timer (&l2cb.rcv_hold_tle, BTU_TTYPE_L2CAP_HOLD, BT_1SEC_TIMEOUT); } @@ -984,7 +984,7 @@ UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flags) if (p_ccb->cong_sent) { L2CAP_TRACE_ERROR ("L2CAP - CID: 0x%04x cannot send, already congested xmit_hold_q.count: %u buff_quota: %u", - p_ccb->local_cid, p_ccb->xmit_hold_q.count, p_ccb->buff_quota); + p_ccb->local_cid, GKI_queue_length(&p_ccb->xmit_hold_q), p_ccb->buff_quota); GKI_freebuf (p_data); return (L2CAP_DW_FAILED); -- cgit v1.2.3 From 770d41fc45514c2020b904f547e3b72f74c3e2db Mon Sep 17 00:00:00 2001 From: Zach Johnson Date: Fri, 29 Aug 2014 13:23:07 -0700 Subject: Remove always false macro L2CAP_HOST_FLOW_CTRL --- stack/l2cap/l2c_main.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'stack/l2cap/l2c_main.c') diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c index 1b45713e0..bd0e478db 100755 --- a/stack/l2cap/l2c_main.c +++ b/stack/l2cap/l2c_main.c @@ -181,12 +181,6 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) STREAM_TO_UINT16 (hci_len, p); p_msg->offset += 4; -#if (L2CAP_HOST_FLOW_CTRL == TRUE) - /* Send ack if we hit the threshold */ - if (++p_lcb->link_pkts_unacked >= p_lcb->link_ack_thresh) - btu_hcif_send_host_rdy_for_data(); -#endif - /* Extract the length and CID */ STREAM_TO_UINT16 (l2cap_len, p); STREAM_TO_UINT16 (rcv_cid, p); -- cgit v1.2.3 From f857d64505d81ce0834de150b79b333a4ff445f2 Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Fri, 26 Sep 2014 13:31:41 -0700 Subject: Remove HCI access macros And some other minor bt_target cleanup. --- stack/l2cap/l2c_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stack/l2cap/l2c_main.c') diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c index bd0e478db..6324c1120 100755 --- a/stack/l2cap/l2c_main.c +++ b/stack/l2cap/l2c_main.c @@ -101,7 +101,7 @@ void l2c_bcst_msg( BT_HDR *p_buf, UINT16 psm ) if (p_buf->len <= btu_cb.hcit_acl_pkt_size) { - HCI_ACL_DATA_TO_LOWER (p_buf); + bte_main_hci_send(p_buf, BT_EVT_TO_LM_HCI_ACL); } } -- cgit v1.2.3 From 30e58068c1adaac7c5ccb3aa9cfb045d41d2a10e Mon Sep 17 00:00:00 2001 From: Zach Johnson Date: Fri, 26 Sep 2014 21:14:34 -0700 Subject: Refactor btm_devctl reset sequence * Controller bring up on blockable thread now * Removed some duplicate and commands during controller bring up * The code to make commands for controller bring up is smaller and better --- stack/l2cap/l2c_main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'stack/l2cap/l2c_main.c') diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c index 6324c1120..4ca28ebee 100755 --- a/stack/l2cap/l2c_main.c +++ b/stack/l2cap/l2c_main.c @@ -27,6 +27,7 @@ #include #include +#include "controller.h" #include "gki.h" #include "hcimsgs.h" #include "l2cdefs.h" @@ -82,10 +83,11 @@ void l2c_bcst_msg( BT_HDR *p_buf, UINT16 psm ) /* First, the HCI transport header */ UINT16_TO_STREAM (p, 0x0050 | (L2CAP_PKT_START << 12) | (2 << 14)); + uint16_t acl_data_size = controller_get_interface()->get_acl_data_size_classic(); /* The HCI transport will segment the buffers. */ - if (p_buf->len > btu_cb.hcit_acl_data_size) + if (p_buf->len > acl_data_size) { - UINT16_TO_STREAM (p, btu_cb.hcit_acl_data_size); + UINT16_TO_STREAM (p, acl_data_size); } else { @@ -99,7 +101,7 @@ void l2c_bcst_msg( BT_HDR *p_buf, UINT16 psm ) p_buf->len += HCI_DATA_PREAMBLE_SIZE; - if (p_buf->len <= btu_cb.hcit_acl_pkt_size) + if (p_buf->len <= controller_get_interface()->get_acl_packet_size_classic()) { bte_main_hci_send(p_buf, BT_EVT_TO_LM_HCI_ACL); } -- cgit v1.2.3 From 86a56d303fdbed734549b181622ed74140113d2d Mon Sep 17 00:00:00 2001 From: Zach Johnson Date: Mon, 20 Oct 2014 11:43:02 -0700 Subject: Remove always false TCS_INCLUDED macro & friends Referenced non existent headers, so would not compile if set to true. --- stack/l2cap/l2c_main.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'stack/l2cap/l2c_main.c') diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c index 4ca28ebee..caef05f2e 100755 --- a/stack/l2cap/l2c_main.c +++ b/stack/l2cap/l2c_main.c @@ -48,10 +48,6 @@ static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len); tL2C_CB l2cb; #endif -/* Temporary - until l2cap implements group management */ -#if (TCS_BCST_SETUP_INCLUDED == TRUE && TCS_INCLUDED == TRUE) -extern void tcs_proc_bcst_msg( BD_ADDR addr, BT_HDR *p_msg ) ; -#endif /******************************************************************************* ** ** Function l2c_bcst_msg @@ -230,16 +226,6 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) /* process_connectionless_data (p_lcb); */ STREAM_TO_UINT16 (psm, p); L2CAP_TRACE_DEBUG( "GOT CONNECTIONLESS DATA PSM:%d", psm ) ; -#if (TCS_BCST_SETUP_INCLUDED == TRUE && TCS_INCLUDED == TRUE) - if (psm == TCS_PSM_INTERCOM || psm == TCS_PSM_CORDLESS) - { - p_msg->offset += L2CAP_BCST_OVERHEAD; - p_msg->len -= L2CAP_BCST_OVERHEAD; - tcs_proc_bcst_msg( p_lcb->remote_bd_addr, p_msg ) ; - GKI_freebuf (p_msg); - } - else -#endif #if (L2CAP_UCD_INCLUDED == TRUE) /* if it is not broadcast, check UCD registration */ -- cgit v1.2.3 From cccf02fadb2dd4dceb22f2d58ed5840b0ef1860e Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Tue, 21 Oct 2014 13:55:24 -0700 Subject: Instrument data flow a bit Use counters to grab some select data metrics. --- stack/l2cap/l2c_main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'stack/l2cap/l2c_main.c') diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c index caef05f2e..e59b76008 100755 --- a/stack/l2cap/l2c_main.c +++ b/stack/l2cap/l2c_main.c @@ -28,6 +28,7 @@ #include #include "controller.h" +#include "counter.h" #include "gki.h" #include "hcimsgs.h" #include "l2cdefs.h" @@ -99,6 +100,9 @@ void l2c_bcst_msg( BT_HDR *p_buf, UINT16 psm ) if (p_buf->len <= controller_get_interface()->get_acl_packet_size_classic()) { + counter_add("l2cap.ch2.tx.bytes", p_buf->len); + counter_add("l2cap.ch2.tx.pkts", 1); + bte_main_hci_send(p_buf, BT_EVT_TO_LM_HCI_ACL); } } @@ -218,11 +222,15 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) /* Send the data through the channel state machine */ if (rcv_cid == L2CAP_SIGNALLING_CID) { + counter_add("l2cap.sig.rx.bytes", l2cap_len); + counter_add("l2cap.sig.rx.pkts", 1); process_l2cap_cmd (p_lcb, p, l2cap_len); GKI_freebuf (p_msg); } else if (rcv_cid == L2CAP_CONNECTIONLESS_CID) { + counter_add("l2cap.ch2.rx.bytes", l2cap_len); + counter_add("l2cap.ch2.rx.pkts", 1); /* process_connectionless_data (p_lcb); */ STREAM_TO_UINT16 (psm, p); L2CAP_TRACE_DEBUG( "GOT CONNECTIONLESS DATA PSM:%d", psm ) ; @@ -240,6 +248,8 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) #if (BLE_INCLUDED == TRUE) else if (rcv_cid == L2CAP_BLE_SIGNALLING_CID) { + counter_add("l2cap.ble.rx.bytes", l2cap_len); + counter_add("l2cap.ble.rx.pkts", 1); l2cble_process_sig_cmd (p_lcb, p, l2cap_len); GKI_freebuf (p_msg); } @@ -248,6 +258,8 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) else if ((rcv_cid >= L2CAP_FIRST_FIXED_CHNL) && (rcv_cid <= L2CAP_LAST_FIXED_CHNL) && (l2cb.fixed_reg[rcv_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb != NULL) ) { + counter_add("l2cap.fix.rx.bytes", l2cap_len); + counter_add("l2cap.fix.rx.pkts", 1); /* If no CCB for this channel, allocate one */ if (p_lcb && /* discard fixed channel data when link is disconnecting */ @@ -272,6 +284,8 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) else { + counter_add("l2cap.dyn.rx.bytes", l2cap_len); + counter_add("l2cap.dyn.rx.pkts", 1); if (p_ccb == NULL) GKI_freebuf (p_msg); else @@ -972,6 +986,9 @@ UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flags) return (L2CAP_DW_FAILED); } + counter_add("l2cap.dyn.tx.bytes", p_data->len); + counter_add("l2cap.dyn.tx.pkts", 1); + l2c_csm_execute (p_ccb, L2CEVT_L2CA_DATA_WRITE, p_data); if (p_ccb->cong_sent) -- cgit v1.2.3 From 79ecab5d0418fde77e9afcdd451bd713af73e180 Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Fri, 31 Oct 2014 14:54:51 -0700 Subject: Move controller module to device directory --- stack/l2cap/l2c_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stack/l2cap/l2c_main.c') diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c index e59b76008..f0de9bb7e 100755 --- a/stack/l2cap/l2c_main.c +++ b/stack/l2cap/l2c_main.c @@ -27,7 +27,7 @@ #include #include -#include "controller.h" +#include "device/include/controller.h" #include "counter.h" #include "gki.h" #include "hcimsgs.h" -- cgit v1.2.3 From 305c15954d69b1a5e15817f6939b907e89100c04 Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Fri, 19 Sep 2014 10:49:50 -0700 Subject: Replace BUFFER_Q with list_t #2 rcv_hold_q -> rcv_pending_q --- stack/l2cap/l2c_main.c | 72 ++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 37 deletions(-) (limited to 'stack/l2cap/l2c_main.c') diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c index f0de9bb7e..e8669289c 100755 --- a/stack/l2cap/l2c_main.c +++ b/stack/l2cap/l2c_main.c @@ -22,20 +22,21 @@ * ******************************************************************************/ -#include "bt_target.h" +#include #include #include #include #include "device/include/controller.h" #include "counter.h" +#include "bt_target.h" +#include "btm_int.h" +#include "btu.h" #include "gki.h" #include "hcimsgs.h" -#include "l2cdefs.h" -#include "l2c_int.h" #include "l2c_api.h" -#include "btu.h" -#include "btm_int.h" +#include "l2c_int.h" +#include "l2cdefs.h" /********************************************************************************/ /* L O C A L F U N C T I O N P R O T O T Y P E S */ @@ -150,23 +151,21 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) STREAM_TO_UINT8 (cmd_code, p); if ((p_msg->layer_specific == 0) && (rcv_cid == L2CAP_SIGNALLING_CID) - && (cmd_code == L2CAP_CMD_INFO_REQ || cmd_code == L2CAP_CMD_CONN_REQ)) - { - L2CAP_TRACE_WARNING ("L2CAP - holding ACL for unknown handle:%d ls:%d cid:%d opcode:%d cur count:%d", - handle, p_msg->layer_specific, rcv_cid, cmd_code, - GKI_queue_length(&l2cb.rcv_hold_q)); + && (cmd_code == L2CAP_CMD_INFO_REQ || cmd_code == L2CAP_CMD_CONN_REQ)) { + L2CAP_TRACE_WARNING ("L2CAP - holding ACL for unknown handle:%d ls:%d" + " cid:%d opcode:%d cur count:%d", handle, p_msg->layer_specific, + rcv_cid, cmd_code, list_length(l2cb.rcv_pending_q)); p_msg->layer_specific = 2; - GKI_enqueue (&l2cb.rcv_hold_q, p_msg); + list_append(l2cb.rcv_pending_q, p_msg); - if (GKI_queue_length(&l2cb.rcv_hold_q) == 1) + if (list_length(l2cb.rcv_pending_q) == 1) btu_start_timer (&l2cb.rcv_hold_tle, BTU_TTYPE_L2CAP_HOLD, BT_1SEC_TIMEOUT); return; - } - else - { - L2CAP_TRACE_ERROR ("L2CAP - rcvd ACL for unknown handle:%d ls:%d cid:%d opcode:%d cur count:%d", - handle, p_msg->layer_specific, rcv_cid, cmd_code, GKI_queue_length(&l2cb.rcv_hold_q)); + } else { + L2CAP_TRACE_ERROR ("L2CAP - rcvd ACL for unknown handle:%d ls:%d cid:%d" + " opcode:%d cur count:%d", handle, p_msg->layer_specific, rcv_cid, + cmd_code, list_length(l2cb.rcv_pending_q)); } GKI_freebuf (p_msg); return; @@ -807,38 +806,30 @@ static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len) ** Returns void ** *******************************************************************************/ -void l2c_process_held_packets (BOOLEAN timed_out) -{ - BT_HDR *p_buf, *p_buf1; - BUFFER_Q *p_rcv_hold_q = &l2cb.rcv_hold_q; - - if (GKI_queue_is_empty(p_rcv_hold_q)) +void l2c_process_held_packets(BOOLEAN timed_out) { + if (list_is_empty(l2cb.rcv_pending_q)) return; - if (!timed_out) - { + if (!timed_out) { btu_stop_timer(&l2cb.rcv_hold_tle); L2CAP_TRACE_WARNING("L2CAP HOLD CONTINUE"); - } - else - { + } else { L2CAP_TRACE_WARNING("L2CAP HOLD TIMEOUT"); } - /* Update the timeouts in the hold queue */ - for (p_buf = (BT_HDR *)GKI_getfirst (p_rcv_hold_q); p_buf; p_buf = p_buf1) - { - p_buf1 = (BT_HDR *)GKI_getnext (p_buf); - if (!timed_out || (!p_buf->layer_specific) || (--p_buf->layer_specific == 0)) - { - GKI_remove_from_queue (p_rcv_hold_q, p_buf); + for (const list_node_t *node = list_begin(l2cb.rcv_pending_q); + node != list_end(l2cb.rcv_pending_q);) { + BT_HDR *p_buf = list_node(node); + node = list_next(node); + if (!timed_out || (!p_buf->layer_specific) || (--p_buf->layer_specific == 0)) { + list_remove(l2cb.rcv_pending_q, p_buf); p_buf->layer_specific = 0xFFFF; - l2c_rcv_acl_data (p_buf); + l2c_rcv_acl_data(p_buf); } } /* If anyone still in the queue, restart the timeout */ - if (!GKI_queue_is_empty(p_rcv_hold_q)) + if (!list_is_empty(l2cb.rcv_pending_q)) btu_start_timer (&l2cb.rcv_hold_tle, BTU_TTYPE_L2CAP_HOLD, BT_1SEC_TIMEOUT); } @@ -901,6 +892,13 @@ void l2c_init (void) l2cb.high_pri_min_xmit_quota = L2CAP_HIGH_PRI_MIN_XMIT_QUOTA; #endif + l2cb.rcv_pending_q = list_new(NULL); + if (l2cb.rcv_pending_q == NULL) + ALOGE("%s unable to allocate memory for link layer control block", __func__); +} + +void l2c_free(void) { + list_free(l2cb.rcv_pending_q); } /******************************************************************************* -- cgit v1.2.3 From 44802768c447ab480d4227b3a852a97d923b816d Mon Sep 17 00:00:00 2001 From: Sharvil Nanavati Date: Tue, 23 Dec 2014 23:08:58 -0800 Subject: Add platform-independent logging macros to OSI. These macros should replace ALOG* and the various trace macros used throughout bluedroid. This change eliminates all uses of the ALOG* macros in favor of the new ones. --- stack/l2cap/l2c_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'stack/l2cap/l2c_main.c') diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c index e8669289c..daef35e1b 100755 --- a/stack/l2cap/l2c_main.c +++ b/stack/l2cap/l2c_main.c @@ -22,7 +22,6 @@ * ******************************************************************************/ -#include #include #include #include @@ -37,6 +36,7 @@ #include "l2c_api.h" #include "l2c_int.h" #include "l2cdefs.h" +#include "osi/include/log.h" /********************************************************************************/ /* L O C A L F U N C T I O N P R O T O T Y P E S */ @@ -894,7 +894,7 @@ void l2c_init (void) l2cb.rcv_pending_q = list_new(NULL); if (l2cb.rcv_pending_q == NULL) - ALOGE("%s unable to allocate memory for link layer control block", __func__); + LOG_ERROR("%s unable to allocate memory for link layer control block", __func__); } void l2c_free(void) { -- cgit v1.2.3 From 95b74f252f534ec757aab1fc08e086e02b2cfe8d Mon Sep 17 00:00:00 2001 From: Sharvil Nanavati Date: Thu, 12 Mar 2015 15:55:21 -0700 Subject: Use fully qualified path for btcore includes. --- stack/l2cap/l2c_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stack/l2cap/l2c_main.c') diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c index daef35e1b..02f12a78b 100755 --- a/stack/l2cap/l2c_main.c +++ b/stack/l2cap/l2c_main.c @@ -27,7 +27,7 @@ #include #include "device/include/controller.h" -#include "counter.h" +#include "btcore/include/counter.h" #include "bt_target.h" #include "btm_int.h" #include "btu.h" -- cgit v1.2.3