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

Commit 8c635e04 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Get rid of direct connect queueing logic

Instead of queueing requests, we should use whitelist to process the
requests simulteanously.
This patch does remove the queueing logic, succeeding patch will add the
logic to schedule through whitelist.

Test: compilation
Bug: 112827989
Change-Id: Ia7132812f704658ecb6919e52c70b291e6874660
parent 7fd3b7f3
Loading
Loading
Loading
Loading
+0 −74
Original line number Diff line number Diff line
@@ -514,80 +514,6 @@ void btm_ble_set_conn_st(tBTM_BLE_CONN_ST new_st) {
    btm_ble_clear_topology_mask(BTM_BLE_STATE_INIT_BIT);
}

/*******************************************************************************
 *
 * Function         btm_ble_enqueue_direct_conn_req
 *
 * Description      This function enqueue the direct connection request
 *
 * Returns          None.
 *
 ******************************************************************************/
void btm_ble_enqueue_direct_conn_req(void* p_param) {
  tBTM_BLE_CONN_REQ* p =
      (tBTM_BLE_CONN_REQ*)osi_malloc(sizeof(tBTM_BLE_CONN_REQ));

  p->p_param = p_param;

  fixed_queue_enqueue(btm_cb.ble_ctr_cb.conn_pending_q, p);
}
/*******************************************************************************
 *
 * Function         btm_ble_dequeue_direct_conn_req
 *
 * Description      This function dequeues the direct connection request
 *
 * Returns          None.
 *
 ******************************************************************************/
void btm_ble_dequeue_direct_conn_req(const RawAddress& rem_bda) {
  if (fixed_queue_is_empty(btm_cb.ble_ctr_cb.conn_pending_q)) return;

  list_t* list = fixed_queue_get_list(btm_cb.ble_ctr_cb.conn_pending_q);
  for (const list_node_t* node = list_begin(list); node != list_end(list);
       node = list_next(node)) {
    tBTM_BLE_CONN_REQ* p_req = (tBTM_BLE_CONN_REQ*)list_node(node);
    tL2C_LCB* p_lcb = (tL2C_LCB*)p_req->p_param;
    if ((p_lcb == NULL) || (!p_lcb->in_use)) {
      continue;
    }
    // If BD address matches
    if (rem_bda == p_lcb->remote_bd_addr) {
      fixed_queue_try_remove_from_queue(btm_cb.ble_ctr_cb.conn_pending_q,
                                        p_req);
      l2cu_release_lcb((tL2C_LCB*)p_req->p_param);
      osi_free((void*)p_req);
      break;
    }
  }
}

/*******************************************************************************
 *
 * Function         btm_send_pending_direct_conn
 *
 * Description      This function send the pending direct connection request in
 *                  queue
 *
 * Returns          true if started, false otherwise
 *
 ******************************************************************************/
bool btm_send_pending_direct_conn(void) {
  tBTM_BLE_CONN_REQ* p_req;
  bool rt = false;

  p_req = (tBTM_BLE_CONN_REQ*)fixed_queue_try_dequeue(
      btm_cb.ble_ctr_cb.conn_pending_q);
  if (p_req != NULL) {
    tL2C_LCB* p_lcb = (tL2C_LCB*)(p_req->p_param);
    /* Ignore entries that might have been released while queued. */
    if (p_lcb->in_use) rt = l2cble_init_direct_conn(p_lcb);
    osi_free(p_req);
  }

  return rt;
}

/** Adds the device into white list. Returns false if white list is full and
 * device can't be added, true otherwise. */
bool BTM_WhiteListAdd(const RawAddress& address) {
+1 −3
Original line number Diff line number Diff line
@@ -2480,8 +2480,7 @@ void btm_ble_update_mode_operation(uint8_t link_role, const RawAddress* bd_addr,
     now in order */
  if (btm_ble_get_conn_st() == BLE_CONN_IDLE &&
      status != HCI_ERR_HOST_REJECT_RESOURCES &&
      status != HCI_ERR_MAX_NUM_OF_CONNECTIONS &&
      !btm_send_pending_direct_conn()) {
      status != HCI_ERR_MAX_NUM_OF_CONNECTIONS) {
    btm_ble_resume_bg_conn();
  }
}
@@ -2508,7 +2507,6 @@ void btm_ble_init(void) {

  p_cb->observer_timer = alarm_new("btm_ble.observer_timer");
  p_cb->cur_states = 0;
  p_cb->conn_pending_q = fixed_queue_new(SIZE_MAX);

  p_cb->inq_var.adv_mode = BTM_BLE_ADV_DISABLE;
  p_cb->inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE;
+0 −5
Original line number Diff line number Diff line
@@ -141,11 +141,6 @@ extern bool btm_execute_wl_dev_operation(void);
extern void btm_ble_update_link_topology_mask(uint8_t role, bool increase);
extern void btm_ble_bgconn_cancel_if_disconnected(const RawAddress& bd_addr);

/* direct connection utility */
extern bool btm_send_pending_direct_conn(void);
extern void btm_ble_enqueue_direct_conn_req(void* p_param);
extern void btm_ble_dequeue_direct_conn_req(const RawAddress& rem_bda);

/* BLE address management */
extern void btm_gen_resolvable_private_addr(
    base::Callback<void(const RawAddress& rpa)> cb);
+0 −1
Original line number Diff line number Diff line
@@ -292,7 +292,6 @@ typedef struct {
  /* white list information */
  uint8_t wl_state;

  fixed_queue_t* conn_pending_q;
  tBTM_BLE_CONN_ST conn_state;

  /* random address management control block */
+3 −41
Original line number Diff line number Diff line
@@ -75,8 +75,6 @@ bool L2CA_CancelBleConnectReq(const RawAddress& rem_bda) {
    LOG(WARNING) << __func__
                 << " different BDA Connecting: " << l2cb.ble_connecting_bda
                 << " Cancel: " << rem_bda;

    btm_ble_dequeue_direct_conn_req(rem_bda);
    return (false);
  }

@@ -782,16 +780,9 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) {
  }
}

/*******************************************************************************
 *
 * Function         l2cble_init_direct_conn
 *
 * Description      This function is to initate a direct connection
 *
 * Returns          true connection initiated, false otherwise.
 *
 ******************************************************************************/
bool l2cble_init_direct_conn(tL2C_LCB* p_lcb) {
/** This function is to initate a direct connection. Returns true if connection
 * initiated, false otherwise. */
bool l2cble_create_conn(tL2C_LCB* p_lcb) {
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_or_alloc_dev(p_lcb->remote_bd_addr);
  tBTM_BLE_CB* p_cb = &btm_cb.ble_ctr_cb;
  uint16_t scan_int = (p_cb->scan_int == BTM_BLE_SCAN_PARAM_UNDEF)
@@ -875,35 +866,6 @@ bool l2cble_init_direct_conn(tL2C_LCB* p_lcb) {
  return (true);
}

/*******************************************************************************
 *
 * Function         l2cble_create_conn
 *
 * Description      This function initiates an acl connection via HCI
 *
 * Returns          true if successful, false if connection not started.
 *
 ******************************************************************************/
bool l2cble_create_conn(tL2C_LCB* p_lcb) {
  tBTM_BLE_CONN_ST conn_st = btm_ble_get_conn_st();
  bool rt = false;

  /* There can be only one BLE connection request outstanding at a time */
  if (conn_st == BLE_CONN_IDLE) {
    rt = l2cble_init_direct_conn(p_lcb);
  } else {
    L2CAP_TRACE_WARNING(
        "L2CAP - LE - cannot start new connection at conn st: %d", conn_st);

    btm_ble_enqueue_direct_conn_req(p_lcb);

    if (conn_st == BLE_BG_CONN) btm_ble_suspend_bg_conn();

    rt = true;
  }
  return rt;
}

/*******************************************************************************
 *
 * Function         l2c_link_processs_ble_num_bufs
Loading