OSDN Git Service

Some ERTM values are constant
authorHansong Zhang <hsz@google.com>
Fri, 25 Sep 2020 03:59:13 +0000 (20:59 -0700)
committerHansong Zhang <hsz@google.com>
Sat, 26 Sep 2020 01:06:40 +0000 (18:06 -0700)
Remove unnecessary definition.

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I2cb74575a57262e11ebc389a3f9473702dbb13b4

btif/src/btif_sock_l2cap.cc
internal_include/bt_target.h
stack/avct/avct_api.cc
stack/avct/avct_bcb_act.cc
stack/avct/avct_l2c_br.cc
stack/gap/gap_conn.cc
stack/include/l2c_api.h
stack/l2cap/l2c_api.cc
stack/l2cap/l2c_fcr.cc
stack/l2cap/l2c_utils.cc

index 7b18083..343562c 100644 (file)
@@ -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
index 2b929d6..620029a 100644 (file)
 #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
index ddbcab4..da4c904 100644 (file)
@@ -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,
index 9f813ad..7f27b79 100644 (file)
@@ -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;
index 56eec6d..6dcd79a 100644 (file)
@@ -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);
index 6d73a15..dd702e1 100644 (file)
@@ -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;
 
index 5051b93..4125ebe 100644 (file)
@@ -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;
 
 /**
index 0dbcac8..57c1552 100644 (file)
@@ -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<uint16_t>(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);
   }
 
index 9ef4b3b..719fd59 100644 (file)
@@ -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;
 
index 19a6f1e..5ef27f8 100644 (file)
@@ -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);