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

Commit 2d39afe6 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2CAP: Delete unused API

L2CA_FlowControl, L2CA_SendTestSFrame, L2CA_GetChnlFcrMode,
L2CA_GetBDAddrbyHandle, L2CA_GetCurrentConfig, L2CA_GetConnectionConfig
are unused and we don't need it in shim

Bug: 145847248
Test: compile
Change-Id: Ie91bb7ed4da2d71a82d2fe8b7f8fb577c00e9e86
parent 56a709bc
Loading
Loading
Loading
Loading
+0 −40
Original line number Diff line number Diff line
@@ -257,12 +257,6 @@ bool bluetooth::shim::L2CA_GetPeerFeatures(const RawAddress& bd_addr,
  return false;
}

bool bluetooth::shim::L2CA_GetBDAddrbyHandle(uint16_t handle,
                                             RawAddress& bd_addr) {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return false;
}

/**
 * Fixed Channel APIs
 */
@@ -298,24 +292,6 @@ bool bluetooth::shim::L2CA_RemoveFixedChnl(uint16_t fixed_cid,
  return false;
}

/**
 * Channel Configuration API
 */
bool bluetooth::shim::L2CA_GetCurrentConfig(
    uint16_t lcid, tL2CAP_CFG_INFO** pp_our_cfg,
    tL2CAP_CH_CFG_BITS* p_our_cfg_bits, tL2CAP_CFG_INFO** pp_peer_cfg,
    tL2CAP_CH_CFG_BITS* p_peer_cfg_bits) {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return false;
}

bool bluetooth::shim::L2CA_GetConnectionConfig(uint16_t lcid, uint16_t* mtu,
                                               uint16_t* rcid,
                                               uint16_t* handle) {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return false;
}

/**
 * Channel hygiene APIs
 */
@@ -331,28 +307,12 @@ bool bluetooth::shim::L2CA_SetIdleTimeout(uint16_t cid, uint16_t timeout,
  return false;
}

bool bluetooth::shim::L2CA_FlowControl(uint16_t cid, bool data_enabled) {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return false;
}

bool bluetooth::shim::L2CA_SendTestSFrame(uint16_t cid, uint8_t sup_type,
                                          uint8_t back_track) {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return false;
}

bool bluetooth::shim::L2CA_SetTxPriority(uint16_t cid,
                                         tL2CAP_CHNL_PRIORITY priority) {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return false;
}

uint8_t bluetooth::shim::L2CA_GetChnlFcrMode(uint16_t lcid) {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return 0;
}

bool bluetooth::shim::L2CA_SetFixedChannelTout(const RawAddress& rem_bda,
                                               uint16_t fixed_cid,
                                               uint16_t idle_tout) {
+0 −84
Original line number Diff line number Diff line
@@ -405,30 +405,6 @@ uint16_t L2CA_FlushChannel(uint16_t lcid, uint16_t num_to_flush);
 ******************************************************************************/
bool L2CA_SetAclPriority(const RawAddress& bd_addr, uint8_t priority);

/*******************************************************************************
 *
 * Function         L2CA_FlowControl
 *
 * Description      Higher layers call this function to flow control a channel.
 *
 *                  data_enabled - true data flows, false data is stopped
 *
 * Returns          true if valid channel, else false
 *
 ******************************************************************************/
bool L2CA_FlowControl(uint16_t cid, bool data_enabled);

/*******************************************************************************
 *
 * Function         L2CA_SendTestSFrame
 *
 * Description      Higher layers call this function to send a test S-frame.
 *
 * Returns          true if valid Channel, else false
 *
 ******************************************************************************/
bool L2CA_SendTestSFrame(uint16_t cid, uint8_t sup_type, uint8_t back_track);

/*******************************************************************************
 *
 * Function         L2CA_SetTxPriority
@@ -440,8 +416,6 @@ bool L2CA_SendTestSFrame(uint16_t cid, uint8_t sup_type, uint8_t back_track);
 ******************************************************************************/
bool L2CA_SetTxPriority(uint16_t cid, tL2CAP_CHNL_PRIORITY priority);

typedef void(tL2CA_RESERVE_CMPL_CBACK)(void);

/*******************************************************************************
 *
 * Function         L2CA_SetFlushTimeout
@@ -495,33 +469,6 @@ bool L2CA_SetChnlFlushability(uint16_t cid, bool is_flushable);
bool L2CA_GetPeerFeatures(const RawAddress& bd_addr, uint32_t* p_ext_feat,
                          uint8_t* p_chnl_mask);

/*******************************************************************************
 *
 *  Function         L2CA_GetBDAddrbyHandle
 *
 *  Description      Get BD address for the given HCI handle
 *
 *  Parameters:      HCI handle
 *                   BD address of the peer
 *
 *  Return value:    true if found lcb for the given handle, false otherwise
 *
 ******************************************************************************/
bool L2CA_GetBDAddrbyHandle(uint16_t handle, RawAddress& bd_addr);

/*******************************************************************************
 *
 *  Function         L2CA_GetChnlFcrMode
 *
 *  Description      Get the channel FCR mode
 *
 *  Parameters:      Local CID
 *
 *  Return value:    Channel mode
 *
 ******************************************************************************/
uint8_t L2CA_GetChnlFcrMode(uint16_t lcid);

/*******************************************************************************
 *
 *  Function        L2CA_RegisterFixedChannel
@@ -605,37 +552,6 @@ bool L2CA_RemoveFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda);
bool L2CA_SetFixedChannelTout(const RawAddress& rem_bda, uint16_t fixed_cid,
                              uint16_t idle_tout);

/*******************************************************************************
 *
 * Function     L2CA_GetCurrentConfig
 *
 * Description  This function returns configurations of L2CAP channel
 *              pp_our_cfg : pointer of our saved configuration options
 *              p_our_cfg_bits : valid config in bitmap
 *              pp_peer_cfg: pointer of peer's saved configuration options
 *              p_peer_cfg_bits : valid config in bitmap
 *
 * Returns      true if successful
 *
 ******************************************************************************/
bool L2CA_GetCurrentConfig(uint16_t lcid, tL2CAP_CFG_INFO** pp_our_cfg,
                           tL2CAP_CH_CFG_BITS* p_our_cfg_bits,
                           tL2CAP_CFG_INFO** pp_peer_cfg,
                           tL2CAP_CH_CFG_BITS* p_peer_cfg_bits);

/*******************************************************************************
 *
 * Function     L2CA_GetConnectionConfig
 *
 * Description  This function polulates the mtu, remote cid & lm_handle for
 *              a given local L2CAP channel
 *
 * Returns      true if successful
 *
 ******************************************************************************/
bool L2CA_GetConnectionConfig(uint16_t lcid, uint16_t* mtu, uint16_t* rcid,
                              uint16_t* handle);

/*******************************************************************************
 *
 *  Function        L2CA_CancelBleConnectReq
+0 −107
Original line number Diff line number Diff line
@@ -85,28 +85,6 @@ typedef uint8_t tL2CAP_CHNL_DATA_RATE;
#define L2CAP_FLUSH_CHANS_ALL 0xffff
#define L2CAP_FLUSH_CHANS_GET 0x0000

/* special CID for Multi-AV for reporting congestion */
#define L2CAP_MULTI_AV_CID 0

/* length of the HCI header block */
/* HCI header(4) + SNK count(1) + FCR bits(1) + AV data length(2) */
#define L2CAP_MULTI_AV_HCI_HDR_LEN 8

/* length of padding for 4 bytes align */
#define L2CAP_MULTI_AV_PADDING_LEN 2

/* length of the HCI header block with padding for FCR */
/* HCI header(4) + SNK count(1) + FCR bits(1) + AV data length(2) + padding(2)
 */
#define L2CAP_MULTI_AV_HCI_HDR_LEN_WITH_PADDING 10

/* length of the L2CAP header block */
/* HCI header(4) + L2CAP header(4) + padding(4) or control word(2) + FCS(2) */
#define L2CAP_MULTI_AV_L2C_HDR_LEN 12

/* definition used for L2CA_SetDesireRole */
#define L2CAP_ROLE_SLAVE HCI_ROLE_SLAVE
#define L2CAP_ROLE_MASTER HCI_ROLE_MASTER
/* set this bit to allow switch at create conn */
#define L2CAP_ROLE_ALLOW_SWITCH 0x80
/* set this bit to disallow switch at create conn */
@@ -714,31 +692,6 @@ extern uint16_t L2CA_FlushChannel(uint16_t lcid, uint16_t num_to_flush);
 ******************************************************************************/
extern bool L2CA_SetAclPriority(const RawAddress& bd_addr, uint8_t priority);

/*******************************************************************************
 *
 * Function         L2CA_FlowControl
 *
 * Description      Higher layers call this function to flow control a channel.
 *
 *                  data_enabled - true data flows, false data is stopped
 *
 * Returns          true if valid channel, else false
 *
 ******************************************************************************/
extern bool L2CA_FlowControl(uint16_t cid, bool data_enabled);

/*******************************************************************************
 *
 * Function         L2CA_SendTestSFrame
 *
 * Description      Higher layers call this function to send a test S-frame.
 *
 * Returns          true if valid Channel, else false
 *
 ******************************************************************************/
extern bool L2CA_SendTestSFrame(uint16_t cid, uint8_t sup_type,
                                uint8_t back_track);

/*******************************************************************************
 *
 * Function         L2CA_SetTxPriority
@@ -750,8 +703,6 @@ extern bool L2CA_SendTestSFrame(uint16_t cid, uint8_t sup_type,
 ******************************************************************************/
extern bool L2CA_SetTxPriority(uint16_t cid, tL2CAP_CHNL_PRIORITY priority);

typedef void(tL2CA_RESERVE_CMPL_CBACK)(void);

/*******************************************************************************
 *
 * Function         L2CA_SetFlushTimeout
@@ -806,33 +757,6 @@ extern bool L2CA_SetChnlFlushability(uint16_t cid, bool is_flushable);
extern bool L2CA_GetPeerFeatures(const RawAddress& bd_addr,
                                 uint32_t* p_ext_feat, uint8_t* p_chnl_mask);

/*******************************************************************************
 *
 *  Function         L2CA_GetBDAddrbyHandle
 *
 *  Description      Get BD address for the given HCI handle
 *
 *  Parameters:      HCI handle
 *                   BD address of the peer
 *
 *  Return value:    true if found lcb for the given handle, false otherwise
 *
 ******************************************************************************/
extern bool L2CA_GetBDAddrbyHandle(uint16_t handle, RawAddress& bd_addr);

/*******************************************************************************
 *
 *  Function         L2CA_GetChnlFcrMode
 *
 *  Description      Get the channel FCR mode
 *
 *  Parameters:      Local CID
 *
 *  Return value:    Channel mode
 *
 ******************************************************************************/
extern uint8_t L2CA_GetChnlFcrMode(uint16_t lcid);

/*******************************************************************************
 *
 *                      Fixed Channel callback prototypes
@@ -965,37 +889,6 @@ extern bool L2CA_SetFixedChannelTout(const RawAddress& rem_bda,

#endif /* (L2CAP_NUM_FIXED_CHNLS > 0) */

/*******************************************************************************
 *
 * Function     L2CA_GetCurrentConfig
 *
 * Description  This function returns configurations of L2CAP channel
 *              pp_our_cfg : pointer of our saved configuration options
 *              p_our_cfg_bits : valid config in bitmap
 *              pp_peer_cfg: pointer of peer's saved configuration options
 *              p_peer_cfg_bits : valid config in bitmap
 *
 * Returns      true if successful
 *
 ******************************************************************************/
extern bool L2CA_GetCurrentConfig(uint16_t lcid, tL2CAP_CFG_INFO** pp_our_cfg,
                                  tL2CAP_CH_CFG_BITS* p_our_cfg_bits,
                                  tL2CAP_CFG_INFO** pp_peer_cfg,
                                  tL2CAP_CH_CFG_BITS* p_peer_cfg_bits);

/*******************************************************************************
 *
 * Function     L2CA_GetConnectionConfig
 *
 * Description  This function polulates the mtu, remote cid & lm_handle for
 *              a given local L2CAP channel
 *
 * Returns      true if successful
 *
 ******************************************************************************/
extern bool L2CA_GetConnectionConfig(uint16_t lcid, uint16_t* mtu,
                                     uint16_t* rcid, uint16_t* handle);

/*******************************************************************************
 *
 *  Function        L2CA_CancelBleConnectReq
+0 −232
Original line number Diff line number Diff line
@@ -1287,95 +1287,6 @@ bool L2CA_SetAclPriority(const RawAddress& bd_addr, uint8_t priority) {
  return (l2cu_set_acl_priority(bd_addr, priority, false));
}

/*******************************************************************************
 *
 * Function         L2CA_FlowControl
 *
 * Description      Higher layers call this function to flow control a channel.
 *
 *                  data_enabled - true data flows, false data is stopped
 *
 * Returns          true if valid channel, else false
 *
 ******************************************************************************/
bool L2CA_FlowControl(uint16_t cid, bool data_enabled) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::L2CA_FlowControl(cid, data_enabled);
  }

  tL2C_CCB* p_ccb;
  bool on_off = !data_enabled;

  L2CAP_TRACE_API("L2CA_FlowControl(%d)  CID: 0x%04x", on_off, cid);

  /* Find the channel control block. We don't know the link it is on. */
  p_ccb = l2cu_find_ccb_by_cid(NULL, cid);
  if (p_ccb == NULL) {
    L2CAP_TRACE_WARNING(
        "L2CAP - no CCB for L2CA_FlowControl, CID: 0x%04x  data_enabled: %d",
        cid, data_enabled);
    return (false);
  }

  if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_ERTM_MODE) {
    L2CAP_TRACE_EVENT("L2CA_FlowControl()  invalid mode:%d",
                      p_ccb->peer_cfg.fcr.mode);
    return (false);
  }
  if (p_ccb->fcrb.local_busy != on_off) {
    p_ccb->fcrb.local_busy = on_off;

    if ((p_ccb->chnl_state == CST_OPEN) && (!p_ccb->fcrb.wait_ack)) {
      if (on_off)
        l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RNR, 0);
      else
        l2c_fcr_send_S_frame(p_ccb, L2CAP_FCR_SUP_RR, L2CAP_FCR_P_BIT);
    }
  }

  return (true);
}

/*******************************************************************************
 *
 * Function         L2CA_SendTestSFrame
 *
 * Description      Higher layers call this function to send a test S-frame.
 *
 * Returns          true if valid Channel, else false
 *
 ******************************************************************************/
bool L2CA_SendTestSFrame(uint16_t cid, uint8_t sup_type, uint8_t back_track) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::L2CA_SendTestSFrame(cid, sup_type, back_track);
  }

  tL2C_CCB* p_ccb;

  L2CAP_TRACE_API(
      "L2CA_SendTestSFrame()  CID: 0x%04x  Type: 0x%02x  back_track: %u", cid,
      sup_type, back_track);

  /* Find the channel control block. We don't know the link it is on. */
  p_ccb = l2cu_find_ccb_by_cid(NULL, cid);
  if (p_ccb == NULL) {
    L2CAP_TRACE_WARNING("L2CAP - no CCB for L2CA_SendTestSFrame, CID: %d", cid);
    return (false);
  }

  if ((p_ccb->chnl_state != CST_OPEN) ||
      (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_ERTM_MODE))
    return (false);

  p_ccb->fcrb.next_seq_expected -= back_track;

  l2c_fcr_send_S_frame(
      p_ccb, (uint16_t)(sup_type & 3),
      (uint16_t)(sup_type & (L2CAP_FCR_P_BIT | L2CAP_FCR_F_BIT)));

  return (true);
}

/*******************************************************************************
 *
 * Function         L2CA_SetTxPriority
@@ -1547,63 +1458,6 @@ bool L2CA_GetPeerFeatures(const RawAddress& bd_addr, uint32_t* p_ext_feat,
  return true;
}

/*******************************************************************************
 *
 *  Function         L2CA_GetBDAddrbyHandle
 *
 *  Description      Get BD address for the given HCI handle
 *
 *  Parameters:      HCI handle
 *                   BD address of the peer
 *
 *  Return value:    true if found lcb for the given handle, false otherwise
 *
 ******************************************************************************/
bool L2CA_GetBDAddrbyHandle(uint16_t handle, RawAddress& bd_addr) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::L2CA_GetBDAddrbyHandle(handle, bd_addr);
  }

  tL2C_LCB* p_lcb = NULL;
  bool found_dev = false;

  p_lcb = l2cu_find_lcb_by_handle(handle);
  if (p_lcb) {
    found_dev = true;
    bd_addr = p_lcb->remote_bd_addr;
  }

  return found_dev;
}

/*******************************************************************************
 *
 *  Function         L2CA_GetChnlFcrMode
 *
 *  Description      Get the channel FCR mode
 *
 *  Parameters:      Local CID
 *
 *  Return value:    Channel mode
 *
 ******************************************************************************/
uint8_t L2CA_GetChnlFcrMode(uint16_t lcid) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::L2CA_GetChnlFcrMode(lcid);
  }

  tL2C_CCB* p_ccb = l2cu_find_ccb_by_cid(NULL, lcid);

  if (p_ccb) {
    L2CAP_TRACE_API("L2CA_GetChnlFcrMode() returns mode %d",
                    p_ccb->peer_cfg.fcr.mode);
    return (p_ccb->peer_cfg.fcr.mode);
  }

  L2CAP_TRACE_API("L2CA_GetChnlFcrMode() returns mode L2CAP_FCR_BASIC_MODE");
  return (L2CAP_FCR_BASIC_MODE);
}

#if (L2CAP_NUM_FIXED_CHNLS > 0)
/*******************************************************************************
 *
@@ -1998,92 +1852,6 @@ bool L2CA_SetFixedChannelTout(const RawAddress& rem_bda, uint16_t fixed_cid,

#endif /* #if (L2CAP_NUM_FIXED_CHNLS > 0) */

/*******************************************************************************
 *
 * Function     L2CA_GetCurrentConfig
 *
 * Description  This function returns configurations of L2CAP channel
 *              pp_our_cfg : pointer of our saved configuration options
 *              p_our_cfg_bits : valid config in bitmap
 *              pp_peer_cfg: pointer of peer's saved configuration options
 *              p_peer_cfg_bits : valid config in bitmap
 *
 * Returns      true if successful
 *
 ******************************************************************************/
bool L2CA_GetCurrentConfig(uint16_t lcid, tL2CAP_CFG_INFO** pp_our_cfg,
                           tL2CAP_CH_CFG_BITS* p_our_cfg_bits,
                           tL2CAP_CFG_INFO** pp_peer_cfg,
                           tL2CAP_CH_CFG_BITS* p_peer_cfg_bits) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::L2CA_GetCurrentConfig(
        lcid, pp_our_cfg, p_our_cfg_bits, pp_peer_cfg, p_peer_cfg_bits);
  }

  tL2C_CCB* p_ccb;

  L2CAP_TRACE_API("L2CA_GetCurrentConfig()  CID: 0x%04x", lcid);

  p_ccb = l2cu_find_ccb_by_cid(NULL, lcid);

  if (p_ccb) {
    *pp_our_cfg = &(p_ccb->our_cfg);

    /* convert valid config items into bitmap */
    *p_our_cfg_bits = 0;
    if (p_ccb->our_cfg.mtu_present) *p_our_cfg_bits |= L2CAP_CH_CFG_MASK_MTU;
    if (p_ccb->our_cfg.qos_present) *p_our_cfg_bits |= L2CAP_CH_CFG_MASK_QOS;
    if (p_ccb->our_cfg.flush_to_present)
      *p_our_cfg_bits |= L2CAP_CH_CFG_MASK_FLUSH_TO;
    if (p_ccb->our_cfg.fcr_present) *p_our_cfg_bits |= L2CAP_CH_CFG_MASK_FCR;
    if (p_ccb->our_cfg.fcs_present) *p_our_cfg_bits |= L2CAP_CH_CFG_MASK_FCS;
    if (p_ccb->our_cfg.ext_flow_spec_present)
      *p_our_cfg_bits |= L2CAP_CH_CFG_MASK_EXT_FLOW_SPEC;

    *pp_peer_cfg = &(p_ccb->peer_cfg);
    *p_peer_cfg_bits = p_ccb->peer_cfg_bits;

    return true;
  } else {
    L2CAP_TRACE_ERROR("No CCB for CID:0x%04x", lcid);
    return false;
  }
}

/*******************************************************************************
 *
 * Function      L2CA_GetConnectionConfig
 *
 * Description  This function returns configurations of L2CAP channel
 *              pp_l2c_ccb : pointer to this channels L2CAP ccb data.
 *
 * Returns      true if successful
 *
 ******************************************************************************/
bool L2CA_GetConnectionConfig(uint16_t lcid, uint16_t* mtu, uint16_t* rcid,
                              uint16_t* handle) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::L2CA_GetConnectionConfig(lcid, mtu, rcid, handle);
  }

  tL2C_CCB* p_ccb = l2cu_find_ccb_by_cid(NULL, lcid);
  ;

  L2CAP_TRACE_API("%s CID: 0x%04x", __func__, lcid);

  if (p_ccb) {
    *mtu = L2CAP_MTU_SIZE;
    if (p_ccb->our_cfg.mtu_present) *mtu = p_ccb->our_cfg.mtu;

    *rcid = p_ccb->remote_cid;
    *handle = p_ccb->p_lcb->handle;
    return true;
  }

  L2CAP_TRACE_ERROR("%s No CCB for CID:0x%04x", __func__, lcid);
  return false;
}

/*******************************************************************************
 *
 * Function         L2CA_DataWrite