Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f08048c3 authored by Chris Manton's avatar Chris Manton
Browse files

Inject acl buffer count into l2cap init

Bug: 253511212
Test: gd/cert/run
Tag: #refactor
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines

Change-Id: I183ce0754d7675ae1a897141b013b3a2b2298592
parent 5687b5db
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@ void BTM_reset_complete() {

  btm_pm_reset();

  l2c_link_init();
  l2c_link_init(controller->get_acl_buffer_count_classic());

  // setup the random number generator
  std::srand(std::time(nullptr));
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@

extern void l2cu_set_non_flushable_pbf(bool is_supported);

extern void l2c_link_init();
extern void l2c_link_init(const uint16_t acl_buffer_count_classic);

extern void l2c_link_processs_ble_num_bufs(uint16_t num_lm_acl_bufs);

+3 −6
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@

#include <cstdint>

#include "device/include/controller.h"
#include "main/shim/l2c_api.h"
#include "main/shim/shim.h"
#include "osi/include/allocator.h"
@@ -747,16 +746,14 @@ void l2c_link_adjust_chnl_allocation(void) {
  }
}

void l2c_link_init() {
void l2c_link_init(const uint16_t acl_buffer_count_classic) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    // GD L2cap gets this info through GD ACL
    return;
  }

  const controller_t* controller = controller_get_interface();

  l2cb.num_lm_acl_bufs = controller->get_acl_buffer_count_classic();
  l2cb.controller_xmit_window = controller->get_acl_buffer_count_classic();
  l2cb.num_lm_acl_bufs = acl_buffer_count_classic;
  l2cb.controller_xmit_window = acl_buffer_count_classic;
}

/*******************************************************************************
+11 −0
Original line number Diff line number Diff line
@@ -194,3 +194,14 @@ TEST_F(StackL2capChannelTest, l2c_lcc_proc_pdu__NextSegment) {

  l2c_lcc_proc_pdu(&ccb_, p_buf);
}

TEST_F(StackL2capChannelTest, l2c_link_init) {
  l2cb.num_lm_acl_bufs = 0;
  l2cb.controller_xmit_window = 0;

  l2c_link_init(controller_.get_acl_buffer_count_classic());

  ASSERT_EQ(controller_.get_acl_buffer_count_classic(), l2cb.num_lm_acl_bufs);
  ASSERT_EQ(controller_.get_acl_buffer_count_classic(),
            l2cb.controller_xmit_window);
}
+4 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ extern std::map<std::string, int> mock_function_count_map;
#include "stack/include/bt_hdr.h"
#include "stack/l2cap/l2c_int.h"
#include "types/raw_address.h"

BT_HDR* l2cu_get_next_buffer_to_send(tL2C_LCB* p_lcb) {
  mock_function_count_map[__func__]++;
  return nullptr;
@@ -66,7 +67,9 @@ void l2c_link_hci_conn_comp(tHCI_STATUS status, uint16_t handle,
void l2c_link_hci_conn_req(const RawAddress& bd_addr) {
  mock_function_count_map[__func__]++;
}
void l2c_link_init() { mock_function_count_map[__func__]++; }
void l2c_link_init(const uint16_t acl_buffer_count_classic) {
  mock_function_count_map[__func__]++;
}
void l2c_link_role_changed(const RawAddress* bd_addr, uint8_t new_role,
                           uint8_t hci_status) {
  mock_function_count_map[__func__]++;