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

Commit 3545ac7e authored by Chris Manton's avatar Chris Manton
Browse files

Simplify stack/l2cap/::l2c_link_check_send_pkts

Towards proper interfaces

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Id83e752e56388283e87f8869017e435359cb0597
parent d0ab2373
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1567,7 +1567,7 @@ uint16_t L2CA_SendFixedChnlData(uint16_t fixed_cid, const RawAddress& rem_bda,
  l2c_enqueue_peer_data(p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL],
                        p_buf);

  l2c_link_check_send_pkts(p_lcb, NULL, NULL);
  l2c_link_check_send_pkts(p_lcb, 0, NULL);

  // If there is no dynamic CCB on the link, restart the idle timer each time
  // something is sent
+4 −4
Original line number Diff line number Diff line
@@ -812,7 +812,7 @@ static void l2c_csm_config(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {

          /* See if we can forward anything on the hold queue */
          if (!fixed_queue_is_empty(p_ccb->xmit_hold_q)) {
            l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL);
            l2c_link_check_send_pkts(p_ccb->p_lcb, 0, NULL);
          }
        }
      }
@@ -898,7 +898,7 @@ static void l2c_csm_config(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {
      /* See if we can forward anything on the hold queue */
      if ((p_ccb->chnl_state == CST_OPEN) &&
          (!fixed_queue_is_empty(p_ccb->xmit_hold_q))) {
        l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL);
        l2c_link_check_send_pkts(p_ccb->p_lcb, 0, NULL);
      }
      break;

@@ -1069,7 +1069,7 @@ static void l2c_csm_open(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {

    case L2CEVT_L2CA_DATA_WRITE: /* Upper layer data to send */
      l2c_enqueue_peer_data(p_ccb, (BT_HDR*)p_data);
      l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL);
      l2c_link_check_send_pkts(p_ccb->p_lcb, 0, NULL);
      break;

    case L2CEVT_L2CA_CONFIG_REQ: /* Upper layer config req   */
@@ -1114,7 +1114,7 @@ static void l2c_csm_open(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {
        if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE && (cr_cb)) {
          (*cr_cb)(p_ccb->local_cid, credit, p_ccb->peer_conn_cfg.credits);
        }
        l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL);
        l2c_link_check_send_pkts(p_ccb->p_lcb, 0, NULL);
      }
      break;
  }
+3 −3
Original line number Diff line number Diff line
@@ -457,7 +457,7 @@ void l2c_fcr_send_S_frame(tL2C_CCB* p_ccb, uint16_t function_code,
    L2CAP_TRACE_EVENT("                  Buf Len: %u", p_buf->len);
  }

  l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, p_buf);
  l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf);

  p_ccb->fcrb.last_ack_sent = p_ccb->fcrb.next_seq_expected;

@@ -678,7 +678,7 @@ void l2c_fcr_proc_pdu(tL2C_CCB* p_ccb, BT_HDR* p_buf) {
  if ((!fixed_queue_is_empty(p_ccb->fcrb.retrans_q) ||
       !fixed_queue_is_empty(p_ccb->xmit_hold_q)) &&
      (!p_ccb->fcrb.wait_ack) && (!l2c_fcr_is_flow_controlled(p_ccb))) {
    l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL);
    l2c_link_check_send_pkts(p_ccb->p_lcb, 0, NULL);
  }
}

@@ -1479,7 +1479,7 @@ static bool retransmit_i_frames(tL2C_CCB* p_ccb, uint8_t tx_seq) {
    }
  }

  l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL);
  l2c_link_check_send_pkts(p_ccb->p_lcb, 0, NULL);

  if (fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q)) {
    p_ccb->fcrb.num_tries++;
+1 −1
Original line number Diff line number Diff line
@@ -632,7 +632,7 @@ extern void l2cu_adjust_out_mps(tL2C_CCB* p_ccb);
*/
extern void l2c_link_timeout(tL2C_LCB* p_lcb);
extern void l2c_info_resp_timer_timeout(void* data);
extern void l2c_link_check_send_pkts(tL2C_LCB* p_lcb, tL2C_CCB* p_ccb,
extern void l2c_link_check_send_pkts(tL2C_LCB* p_lcb, uint16_t local_cid,
                                     BT_HDR* p_buf);
extern void l2c_link_adjust_allocation(void);

+11 −11
Original line number Diff line number Diff line
@@ -528,7 +528,7 @@ void l2c_link_timeout(tL2C_LCB* p_lcb) {
      }
    } else {
      /* Check in case we were flow controlled */
      l2c_link_check_send_pkts(p_lcb, NULL, NULL);
      l2c_link_check_send_pkts(p_lcb, 0, NULL);
    }
  }
}
@@ -866,17 +866,17 @@ bool l2c_link_check_power_mode(tL2C_LCB* p_lcb) {
 * Returns          void
 *
 ******************************************************************************/
void l2c_link_check_send_pkts(tL2C_LCB* p_lcb, tL2C_CCB* p_ccb, BT_HDR* p_buf) {
void l2c_link_check_send_pkts(tL2C_LCB* p_lcb, uint16_t local_cid,
                              BT_HDR* p_buf) {
  int xx;
  bool single_write = false;

  /* Save the channel ID for faster counting */
  if (p_buf) {
    if (p_ccb != NULL) {
      p_buf->event = p_ccb->local_cid;
    p_buf->event = local_cid;
    if (local_cid != 0) {
      single_write = true;
    } else
      p_buf->event = 0;
    }

    p_buf->layer_specific = 0;
    list_append(p_lcb->link_xmit_data_q, p_buf);
@@ -1007,7 +1007,7 @@ void l2c_OnHciModeChangeSendPendingPackets(RawAddress remote) {
    /* Trigger L2C to start transmission of the pending packets. */
    BTM_TRACE_DEBUG(
        "btm mode change to active; check l2c_link for outgoing packets");
    l2c_link_check_send_pkts(p_lcb, NULL, NULL);
    l2c_link_check_send_pkts(p_lcb, 0, NULL);
  }
}

@@ -1185,19 +1185,19 @@ void l2c_link_process_num_completed_pkts(uint8_t* p, uint8_t evt_len) {
      else
        p_lcb->sent_not_acked = 0;

      l2c_link_check_send_pkts(p_lcb, NULL, NULL);
      l2c_link_check_send_pkts(p_lcb, 0, NULL);

      /* If we were doing round-robin for low priority links, check 'em */
      if ((p_lcb->acl_priority == L2CAP_PRIORITY_HIGH) &&
          (l2cb.check_round_robin) &&
          (l2cb.round_robin_unacked < l2cb.round_robin_quota)) {
        l2c_link_check_send_pkts(NULL, NULL, NULL);
        l2c_link_check_send_pkts(NULL, 0, NULL);
      }
      if ((p_lcb->transport == BT_TRANSPORT_LE) &&
          (p_lcb->acl_priority == L2CAP_PRIORITY_HIGH) &&
          ((l2cb.ble_check_round_robin) &&
           (l2cb.ble_round_robin_unacked < l2cb.ble_round_robin_quota))) {
        l2c_link_check_send_pkts(NULL, NULL, NULL);
        l2c_link_check_send_pkts(NULL, 0, NULL);
      }
    }

@@ -1260,7 +1260,7 @@ void l2c_link_segments_xmitted(BT_HDR* p_msg) {

    p_lcb->partial_segment_being_sent = false;

    l2c_link_check_send_pkts(p_lcb, NULL, NULL);
    l2c_link_check_send_pkts(p_lcb, 0, NULL);
  } else
    osi_free(p_msg);
}
Loading