From: Hansong Zhang Date: Fri, 25 Sep 2020 03:59:13 +0000 (-0700) Subject: Some ERTM values are constant X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1b6d60e504f54b100e58da03a509ac5806fe279b;p=android-x86%2Fsystem-bt.git Some ERTM values are constant Remove unnecessary definition. Bug: 159815595 Tag: #refactor Test: compile & verify basic functions working Change-Id: I2cb74575a57262e11ebc389a3f9473702dbb13b4 --- diff --git a/btif/src/btif_sock_l2cap.cc b/btif/src/btif_sock_l2cap.cc index 7b18083bb..343562c73 100644 --- a/btif/src/btif_sock_l2cap.cc +++ b/btif/src/btif_sock_l2cap.cc @@ -685,10 +685,8 @@ const tL2CAP_FCR_OPTS obex_l2c_fcr_opts_def = { OBX_FCR_OPT_MONITOR_TOUT, /* Monitor timeout (12 secs) */ OBX_FCR_OPT_MAX_PDU_SIZE /* MPS segment size */ }; -const tL2CAP_ERTM_INFO obex_l2c_etm_opt = { - L2CAP_FCR_ERTM_MODE, /* Mandatory for OBEX over l2cap */ - OBX_USER_RX_BUF_SIZE, OBX_USER_TX_BUF_SIZE, - OBX_FCR_RX_BUF_SIZE, OBX_FCR_TX_BUF_SIZE}; +const tL2CAP_ERTM_INFO obex_l2c_etm_opt = {L2CAP_FCR_ERTM_MODE, + /* Mandatory for OBEX over l2cap */}; /** * When using a dynamic PSM, a PSM allocation is requested from diff --git a/internal_include/bt_target.h b/internal_include/bt_target.h index 2b929d629..620029a96 100644 --- a/internal_include/bt_target.h +++ b/internal_include/bt_target.h @@ -168,16 +168,6 @@ #define L2CAP_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE #endif -/* Sends L2CAP segmented packets in ERTM mode */ -#ifndef L2CAP_FCR_TX_BUF_SIZE -#define L2CAP_FCR_TX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE -#endif - -/* Receives L2CAP segmented packets in ERTM mode */ -#ifndef L2CAP_FCR_RX_BUF_SIZE -#define L2CAP_FCR_RX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE -#endif - #ifndef L2CAP_FCR_ERTM_BUF_SIZE #define L2CAP_FCR_ERTM_BUF_SIZE (10240 + 24) #endif diff --git a/stack/avct/avct_api.cc b/stack/avct/avct_api.cc index ddbcab406..da4c90427 100644 --- a/stack/avct/avct_api.cc +++ b/stack/avct/avct_api.cc @@ -66,10 +66,6 @@ void AVCT_Register() { /* Include the browsing channel which uses eFCR */ tL2CAP_ERTM_INFO ertm_info; ertm_info.preferred_mode = L2CAP_FCR_ERTM_MODE; - ertm_info.user_rx_buf_size = BT_DEFAULT_BUFFER_SIZE; - ertm_info.user_tx_buf_size = BT_DEFAULT_BUFFER_SIZE; - ertm_info.fcr_rx_buf_size = BT_DEFAULT_BUFFER_SIZE; - ertm_info.fcr_tx_buf_size = BT_DEFAULT_BUFFER_SIZE; L2CA_Register2(AVCT_BR_PSM, avct_l2c_br_appl, true /*enable_snoop*/, &ertm_info, kAvrcBrMtu, AVCT_MIN_BROWSE_MTU, diff --git a/stack/avct/avct_bcb_act.cc b/stack/avct/avct_bcb_act.cc index 9f813add9..7f27b7994 100644 --- a/stack/avct/avct_bcb_act.cc +++ b/stack/avct/avct_bcb_act.cc @@ -107,10 +107,6 @@ void avct_bcb_chnl_open(tAVCT_BCB* p_bcb, UNUSED_ATTR tAVCT_LCB_EVT* p_data) { /* Set the FCR options: Browsing channel mandates ERTM */ ertm_info.preferred_mode = L2CAP_FCR_ERTM_MODE; - ertm_info.user_rx_buf_size = BT_DEFAULT_BUFFER_SIZE; - ertm_info.user_tx_buf_size = BT_DEFAULT_BUFFER_SIZE; - ertm_info.fcr_rx_buf_size = BT_DEFAULT_BUFFER_SIZE; - ertm_info.fcr_tx_buf_size = BT_DEFAULT_BUFFER_SIZE; /* call l2cap connect req */ p_bcb->ch_state = AVCT_CH_CONN; diff --git a/stack/avct/avct_l2c_br.cc b/stack/avct/avct_l2c_br.cc index 56eec6daa..6dcd79ab1 100644 --- a/stack/avct/avct_l2c_br.cc +++ b/stack/avct/avct_l2c_br.cc @@ -145,10 +145,6 @@ void avct_l2c_br_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid, /* Set the FCR options: Browsing channel mandates ERTM */ ertm_info.preferred_mode = L2CAP_FCR_ERTM_MODE; - ertm_info.user_rx_buf_size = BT_DEFAULT_BUFFER_SIZE; - ertm_info.user_tx_buf_size = BT_DEFAULT_BUFFER_SIZE; - ertm_info.fcr_rx_buf_size = BT_DEFAULT_BUFFER_SIZE; - ertm_info.fcr_tx_buf_size = BT_DEFAULT_BUFFER_SIZE; /* Send L2CAP connect rsp */ L2CA_ErtmConnectRsp(bd_addr, id, lcid, result, 0, &ertm_info); diff --git a/stack/gap/gap_conn.cc b/stack/gap/gap_conn.cc index 6d73a1538..dd702e124 100644 --- a/stack/gap/gap_conn.cc +++ b/stack/gap/gap_conn.cc @@ -228,10 +228,6 @@ uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id, if (p_ccb->cfg.fcr_present) { if (ertm_info == NULL) { p_ccb->ertm_info.preferred_mode = p_ccb->cfg.fcr.mode; - p_ccb->ertm_info.user_rx_buf_size = BT_DEFAULT_BUFFER_SIZE; - p_ccb->ertm_info.user_tx_buf_size = BT_DEFAULT_BUFFER_SIZE; - p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_INVALID_ERM_BUF_SIZE; - p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_INVALID_ERM_BUF_SIZE; } else { p_ccb->ertm_info = *ertm_info; } @@ -771,8 +767,7 @@ static void gap_config_ind(uint16_t l2cap_cid, tL2CAP_CFG_INFO* p_cfg) { /* Remember the remote MTU size */ if (p_ccb->cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) { - local_mtu_size = - p_ccb->ertm_info.user_tx_buf_size - sizeof(BT_HDR) - L2CAP_MIN_OFFSET; + local_mtu_size = BT_DEFAULT_BUFFER_SIZE - sizeof(BT_HDR) - L2CAP_MIN_OFFSET; } else local_mtu_size = L2CAP_MTU_SIZE; diff --git a/stack/include/l2c_api.h b/stack/include/l2c_api.h index 5051b93ea..4125ebe7b 100644 --- a/stack/include/l2c_api.h +++ b/stack/include/l2c_api.h @@ -250,10 +250,6 @@ typedef struct { */ typedef struct { uint8_t preferred_mode; - uint16_t user_rx_buf_size; - uint16_t user_tx_buf_size; - uint16_t fcr_rx_buf_size; - uint16_t fcr_tx_buf_size; } tL2CAP_ERTM_INFO; /** diff --git a/stack/l2cap/l2c_api.cc b/stack/l2cap/l2c_api.cc index 0dbcac807..57c155201 100644 --- a/stack/l2cap/l2c_api.cc +++ b/stack/l2cap/l2c_api.cc @@ -122,7 +122,9 @@ uint16_t L2CA_Register(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, p_rcb->log_packets = enable_snoop; p_rcb->api = p_cb_info; p_rcb->real_psm = psm; - p_rcb->ertm_info = p_ertm_info == nullptr ? tL2CAP_ERTM_INFO{} : *p_ertm_info; + p_rcb->ertm_info = p_ertm_info == nullptr + ? tL2CAP_ERTM_INFO{L2CAP_FCR_BASIC_MODE} + : *p_ertm_info; p_rcb->my_mtu = my_mtu; p_rcb->required_remote_mtu = std::max(required_remote_mtu, L2CAP_MIN_MTU); @@ -399,21 +401,8 @@ uint16_t L2CA_ErtmConnectReq(uint16_t psm, const RawAddress& p_bd_addr, if (p_ertm_info) { p_ccb->ertm_info = *p_ertm_info; - /* Replace default indicators with the actual default pool */ - if (p_ccb->ertm_info.fcr_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) - p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_FCR_RX_BUF_SIZE; - - if (p_ccb->ertm_info.fcr_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) - p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_FCR_TX_BUF_SIZE; - - if (p_ccb->ertm_info.user_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) - p_ccb->ertm_info.user_rx_buf_size = BT_DEFAULT_BUFFER_SIZE; - - if (p_ccb->ertm_info.user_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) - p_ccb->ertm_info.user_tx_buf_size = BT_DEFAULT_BUFFER_SIZE; - p_ccb->max_rx_mtu = - p_ertm_info->user_rx_buf_size - + BT_DEFAULT_BUFFER_SIZE - (L2CAP_MIN_OFFSET + L2CAP_SDU_LEN_OFFSET + L2CAP_FCS_LEN); } @@ -822,21 +811,8 @@ bool L2CA_ErtmConnectRsp(const RawAddress& p_bd_addr, uint8_t id, uint16_t lcid, if (p_ertm_info) { p_ccb->ertm_info = *p_ertm_info; - /* Replace default indicators with the actual default pool */ - if (p_ccb->ertm_info.fcr_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) - p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_FCR_RX_BUF_SIZE; - - if (p_ccb->ertm_info.fcr_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) - p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_FCR_TX_BUF_SIZE; - - if (p_ccb->ertm_info.user_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) - p_ccb->ertm_info.user_rx_buf_size = BT_DEFAULT_BUFFER_SIZE; - - if (p_ccb->ertm_info.user_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) - p_ccb->ertm_info.user_tx_buf_size = BT_DEFAULT_BUFFER_SIZE; - p_ccb->max_rx_mtu = - p_ertm_info->user_rx_buf_size - + BT_DEFAULT_BUFFER_SIZE - (L2CAP_MIN_OFFSET + L2CAP_SDU_LEN_OFFSET + L2CAP_FCS_LEN); } diff --git a/stack/l2cap/l2c_fcr.cc b/stack/l2cap/l2c_fcr.cc index 9ef4b3b05..719fd592d 100644 --- a/stack/l2cap/l2c_fcr.cc +++ b/stack/l2cap/l2c_fcr.cc @@ -1040,24 +1040,6 @@ static void process_i_frame(tL2C_CCB* p_ccb, BT_HDR* p_buf, uint16_t ctrl_word, if ((tx_seq == next_srej) && (fixed_queue_length(p_fcrb->srej_rcv_hold_q) < p_ccb->our_cfg.fcr.tx_win_sz)) { - /* If user gave us a pool for held rx buffers, use that */ - /* TODO: Could that happen? Get rid of this code. */ - if (p_ccb->ertm_info.fcr_rx_buf_size != L2CAP_FCR_RX_BUF_SIZE) { - BT_HDR* p_buf2; - - /* Adjust offset and len so that control word is copied */ - p_buf->offset -= L2CAP_FCR_OVERHEAD; - p_buf->len += L2CAP_FCR_OVERHEAD; - - p_buf2 = l2c_fcr_clone_buf(p_buf, p_buf->offset, p_buf->len); - - if (p_buf2) { - osi_free(p_buf); - p_buf = p_buf2; - } - p_buf->offset += L2CAP_FCR_OVERHEAD; - p_buf->len -= L2CAP_FCR_OVERHEAD; - } L2CAP_TRACE_DEBUG( "process_i_frame() Lost: %u tx_seq:%u ExpTxSeq %u Rej: %u " "SRej1", @@ -1972,7 +1954,7 @@ uint8_t l2c_fcr_process_peer_cfg_req(tL2C_CCB* p_ccb, tL2CAP_CFG_INFO* p_cfg) { p_ccb->peer_cfg.fcs = p_cfg->fcs; } - max_retrans_size = p_ccb->ertm_info.fcr_tx_buf_size - sizeof(BT_HDR) - + max_retrans_size = BT_DEFAULT_BUFFER_SIZE - sizeof(BT_HDR) - L2CAP_MIN_OFFSET - L2CAP_SDU_LEN_OFFSET - L2CAP_FCS_LEN; diff --git a/stack/l2cap/l2c_utils.cc b/stack/l2cap/l2c_utils.cc index 19a6f1ee1..5ef27f856 100644 --- a/stack/l2cap/l2c_utils.cc +++ b/stack/l2cap/l2c_utils.cc @@ -1371,12 +1371,8 @@ tL2C_CCB* l2cu_allocate_ccb(tL2C_LCB* p_lcb, uint16_t cid) { p_ccb->ertm_info.preferred_mode = L2CAP_FCR_BASIC_MODE; /* Default mode for channel is basic mode */ - p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_FCR_RX_BUF_SIZE; - p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_FCR_TX_BUF_SIZE; - p_ccb->ertm_info.user_rx_buf_size = BT_DEFAULT_BUFFER_SIZE; - p_ccb->ertm_info.user_tx_buf_size = BT_DEFAULT_BUFFER_SIZE; p_ccb->max_rx_mtu = L2CAP_MTU_SIZE; - p_ccb->tx_mps = L2CAP_FCR_TX_BUF_SIZE - 32; + p_ccb->tx_mps = BT_DEFAULT_BUFFER_SIZE - 32; p_ccb->xmit_hold_q = fixed_queue_new(SIZE_MAX); p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(SIZE_MAX);