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

Commit a6783b89 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "L2cap: Clean up some COC code"

parents de10dbae 78a8b989
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@

#include <base/logging.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
@@ -33,27 +32,17 @@

#include "osi/include/allocator.h"

#include "bt_common.h"
#include "bt_target.h"
#include "bta_api.h"
#include "bta_jv_api.h"
#include "bta_jv_co.h"
#include "btif_common.h"
#include "btif_sock_sdp.h"
#include "btif_sock_thread.h"
#include "btif_sock_util.h"
#include "btif_uid.h"
#include "btif_util.h"
#include "btm_api.h"
#include "btm_int.h"
#include "btu.h"
#include "common/metrics.h"
#include "hcimsgs.h"
#include "l2c_api.h"
#include "l2c_int.h"
#include "l2cdefs.h"
#include "port_api.h"
#include "sdp_api.h"

struct packet {
  struct packet *next, *prev;
+6 −0
Original line number Diff line number Diff line
@@ -143,6 +143,12 @@ typedef struct {
  uint16_t flags; /* bit 0: 0-no continuation, 1-continuation */
} tL2CAP_CFG_INFO;

/* LE credit based L2CAP connection parameters */
constexpr uint16_t L2CAP_LE_MIN_MTU = 23;  // Minimum SDU size
constexpr uint16_t L2CAP_LE_MIN_MPS = 23;
constexpr uint16_t L2CAP_LE_MAX_MPS = 65533;
constexpr uint16_t L2CAP_LE_CREDIT_MAX = 65535;

// This is initial amout of credits we send, and amount to which we increase
// credits once they fall below threshold
constexpr uint16_t L2CAP_LE_CREDIT_DEFAULT = 0xffff;
+8 −8
Original line number Diff line number Diff line
@@ -972,7 +972,7 @@ static void l2c_csm_open(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {
  tL2C_CHNL_STATE tempstate;
  uint8_t tempcfgdone;
  uint8_t cfg_result;
  uint16_t* credit;
  uint16_t credit = 0;

  L2CAP_TRACE_EVENT("L2CAP - LCID: 0x%04x  st: OPEN  evt: %s", p_ccb->local_cid,
                    l2c_csm_get_event_name(event));
@@ -1095,25 +1095,25 @@ static void l2c_csm_open(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {

    case L2CEVT_L2CA_SEND_FLOW_CONTROL_CREDIT:
      L2CAP_TRACE_DEBUG("%s Sending credit", __func__);
      credit = (uint16_t*)p_data;
      l2cble_send_flow_control_credit(p_ccb, *credit);
      credit = *(uint16_t*)p_data;
      l2cble_send_flow_control_credit(p_ccb, credit);
      break;

    case L2CEVT_L2CAP_RECV_FLOW_CONTROL_CREDIT:
      credit = (uint16_t*)p_data;
      L2CAP_TRACE_DEBUG("%s Credits received %d", __func__, *credit);
      if ((p_ccb->peer_conn_cfg.credits + *credit) > L2CAP_LE_CREDIT_MAX) {
      credit = *(uint16_t*)p_data;
      L2CAP_TRACE_DEBUG("%s Credits received %d", __func__, credit);
      if ((p_ccb->peer_conn_cfg.credits + credit) > L2CAP_LE_CREDIT_MAX) {
        /* we have received credits more than max coc credits,
         * so disconnecting the Le Coc Channel
         */
        l2cble_send_peer_disc_req(p_ccb);
      } else {
        p_ccb->peer_conn_cfg.credits += *credit;
        p_ccb->peer_conn_cfg.credits += credit;

        tL2CA_CREDITS_RECEIVED_CB* cr_cb =
            p_ccb->p_rcb->api.pL2CA_CreditsReceived_Cb;
        if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE && (cr_cb)) {
          (*cr_cb)(p_ccb->local_cid, *credit, p_ccb->peer_conn_cfg.credits);
          (*cr_cb)(p_ccb->local_cid, credit, p_ccb->peer_conn_cfg.credits);
        }
        l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL);
      }
+0 −6
Original line number Diff line number Diff line
@@ -40,12 +40,6 @@

#define L2CAP_MIN_MTU 48 /* Minimum acceptable MTU is 48 bytes */

/* LE credit based L2CAP connection parameters */
constexpr uint16_t L2CAP_LE_MIN_MTU = 23;  // Minimum SDU size
constexpr uint16_t L2CAP_LE_MIN_MPS = 23;
constexpr uint16_t L2CAP_LE_MAX_MPS = 65533;
constexpr uint16_t L2CAP_LE_CREDIT_MAX = 65535;

#define L2CAP_NO_IDLE_TIMEOUT 0xFFFF

/*