OSDN Git Service

Smooth l2c_link_send_to_lower/br_edr and ble
authorChris Manton <cmanton@google.com>
Sat, 22 Aug 2020 15:41:54 +0000 (08:41 -0700)
committerChris Manton <cmanton@google.com>
Sat, 22 Aug 2020 16:26:50 +0000 (09:26 -0700)
stack/l2cap/l2c_link::l2c_link_send_to_lower

Towards proper interfaces

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working

Change-Id: Ia464ddf48f403d542f361b872c7c8a68c5de50af

stack/l2cap/l2c_link.cc

index bb3469d..40bfe49 100644 (file)
@@ -1030,13 +1030,9 @@ static void l2c_link_send_to_lower_br_edr(tL2C_LCB* p_lcb, BT_HDR* p_buf) {
     p_buf->layer_specific = 0;
 
     l2cb.controller_xmit_window--;
-    bte_main_hci_send(p_buf, kDataPacketEventBrEdr);
   } else {
-    uint16_t xmit_window{0};
-    uint16_t acl_data_size{0};
-    acl_data_size = acl_packet_size_classic;
-    xmit_window = l2cb.controller_xmit_window;
-
+    uint16_t xmit_window = l2cb.controller_xmit_window;
+    uint16_t acl_data_size = acl_packet_size_classic;
     uint16_t num_segs =
         (p_buf->len - HCI_DATA_PREAMBLE_SIZE + acl_data_size - 1) /
         acl_data_size;
@@ -1063,8 +1059,8 @@ static void l2c_link_send_to_lower_br_edr(tL2C_LCB* p_lcb, BT_HDR* p_buf) {
     if (p_lcb->link_xmit_quota == 0) l2cb.round_robin_unacked += num_segs;
 
     p_lcb->sent_not_acked += num_segs;
-    bte_main_hci_send(p_buf, kDataPacketEventBrEdr);
   }
+  bte_main_hci_send(p_buf, kDataPacketEventBrEdr);
   L2CAP_TRACE_DEBUG(
       "TotalWin=%d,Hndl=0x%x,Quota=%d,Unack=%d,RRQuota=%d,RRUnack=%d",
       l2cb.controller_xmit_window, p_lcb->handle, p_lcb->link_xmit_quota,
@@ -1085,12 +1081,9 @@ static void l2c_link_send_to_lower_ble(tL2C_LCB* p_lcb, BT_HDR* p_buf) {
     p_buf->layer_specific = 0;
 
     l2cb.controller_le_xmit_window--;
-    bte_main_hci_send(p_buf, kDataPacketEventBle);
   } else {
-    uint16_t xmit_window{0};
-    uint16_t acl_data_size{0};
-    acl_data_size = acl_packet_size_ble;
-    xmit_window = l2cb.controller_le_xmit_window;
+    uint16_t xmit_window = l2cb.controller_le_xmit_window;
+    uint16_t acl_data_size = acl_packet_size_ble;
 
     uint16_t num_segs =
         (p_buf->len - HCI_DATA_PREAMBLE_SIZE + acl_data_size - 1) /
@@ -1118,8 +1111,8 @@ static void l2c_link_send_to_lower_ble(tL2C_LCB* p_lcb, BT_HDR* p_buf) {
     if (p_lcb->link_xmit_quota == 0) l2cb.ble_round_robin_unacked += num_segs;
 
     p_lcb->sent_not_acked += num_segs;
-    bte_main_hci_send(p_buf, kDataPacketEventBle);
   }
+  bte_main_hci_send(p_buf, kDataPacketEventBle);
 
   L2CAP_TRACE_DEBUG(
       "TotalWin=%d,Hndl=0x%x,Quota=%d,Unack=%d,RRQuota=%d,RRUnack=%d",