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

Commit 4b3fe3ed authored by Hansong Zhang's avatar Hansong Zhang Committed by Automerger Merge Worker
Browse files

L2CAP: Provide a default ERTM option am: 2466c710

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1438417

Change-Id: I18acbf65f5eab682de8073b98875f828da5056fa
parents 9a876a61 2466c710
Loading
Loading
Loading
Loading
+2 −12
Original line number Original line Diff line number Diff line
@@ -675,16 +675,6 @@ static void btsock_l2cap_cbk(tBTA_JV_EVT event, tBTA_JV* p_data,
  }
  }
}
}


/* L2CAP default options for OBEX socket connections */
const tL2CAP_FCR_OPTS obex_l2c_fcr_opts_def = {
    L2CAP_FCR_ERTM_MODE,               /* Mandatory for OBEX over l2cap */
    OBX_FCR_OPT_TX_WINDOW_SIZE_BR_EDR, /* Tx window size */
    OBX_FCR_OPT_MAX_TX_B4_DISCNT,      /* Maximum transmissions before
                                          disconnecting */
    OBX_FCR_OPT_RETX_TOUT,             /* Retransmission timeout (2 secs) */
    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,
const tL2CAP_ERTM_INFO obex_l2c_etm_opt = {L2CAP_FCR_ERTM_MODE,
                                           /* Mandatory for OBEX over l2cap */};
                                           /* Mandatory for OBEX over l2cap */};


@@ -723,7 +713,7 @@ static void btsock_l2cap_server_listen(l2cap_socket* sock) {


  /* Setup ETM settings: mtu will be set below */
  /* Setup ETM settings: mtu will be set below */
  std::unique_ptr<tL2CAP_CFG_INFO> cfg = std::make_unique<tL2CAP_CFG_INFO>(
  std::unique_ptr<tL2CAP_CFG_INFO> cfg = std::make_unique<tL2CAP_CFG_INFO>(
      tL2CAP_CFG_INFO{.fcr_present = true, .fcr = obex_l2c_fcr_opts_def});
      tL2CAP_CFG_INFO{.fcr_present = true, .fcr = kDefaultErtmOptions});


  std::unique_ptr<tL2CAP_ERTM_INFO> ertm_info;
  std::unique_ptr<tL2CAP_ERTM_INFO> ertm_info;
  if (!sock->is_le_coc) {
  if (!sock->is_le_coc) {
@@ -771,7 +761,7 @@ static bt_status_t btsock_l2cap_listen_or_connect(const char* name,


      /* Setup ETM settings: mtu will be set below */
      /* Setup ETM settings: mtu will be set below */
      std::unique_ptr<tL2CAP_CFG_INFO> cfg = std::make_unique<tL2CAP_CFG_INFO>(
      std::unique_ptr<tL2CAP_CFG_INFO> cfg = std::make_unique<tL2CAP_CFG_INFO>(
          tL2CAP_CFG_INFO{.fcr_present = true, .fcr = obex_l2c_fcr_opts_def});
          tL2CAP_CFG_INFO{.fcr_present = true, .fcr = kDefaultErtmOptions});


      std::unique_ptr<tL2CAP_ERTM_INFO> ertm_info;
      std::unique_ptr<tL2CAP_ERTM_INFO> ertm_info;
      if (!sock->is_le_coc) {
      if (!sock->is_le_coc) {
+0 −82
Original line number Original line Diff line number Diff line
@@ -762,88 +762,6 @@
#define PORT_FC_DEFAULT PORT_FC_CREDIT
#define PORT_FC_DEFAULT PORT_FC_CREDIT
#endif
#endif


/******************************************************************************
 *
 * OBEX
 *
 *****************************************************************************/

/*
 * Buffer size to reassemble the SDU.
 * It will allow buffers to be used that are larger than the L2CAP_MAX_MTU.
 */
#ifndef OBX_USER_RX_BUF_SIZE
#define OBX_USER_RX_BUF_SIZE OBX_LRG_DATA_BUF_SIZE
#endif

/*
 * Buffer size to hold the SDU.
 * It will allow buffers to be used that are larger than the L2CAP_MAX_MTU.
 */
#ifndef OBX_USER_TX_BUF_SIZE
#define OBX_USER_TX_BUF_SIZE OBX_LRG_DATA_BUF_SIZE
#endif

/* Buffer size used to hold MPS segments during SDU reassembly. */
#ifndef OBX_FCR_RX_BUF_SIZE
#define OBX_FCR_RX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
#endif

/*
 * Buffer size used to hold MPS segments used in (re)transmissions.
 * The size of each buffer must be able to hold the maximum MPS segment size
 * passed in L2CA_SetFCROptions plus BT_HDR (8) + HCI preamble (4) +
 * L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec).
 */
#ifndef OBX_FCR_TX_BUF_SIZE
#define OBX_FCR_TX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
#endif

/*
 * Size of the transmission window when using enhanced retransmission mode.
 * Not used in basic and streaming modes. Range: 1 - 63
 */
#ifndef OBX_FCR_OPT_TX_WINDOW_SIZE_BR_EDR
#define OBX_FCR_OPT_TX_WINDOW_SIZE_BR_EDR 20
#endif

/*
 * Number of transmission attempts for a single I-Frame before taking
 * Down the connection. Used In ERTM mode only. Value is Ignored in basic and
 * Streaming modes.
 * Range: 0, 1-0xFF
 * 0 - infinite retransmissions
 * 1 - single transmission
 */
#ifndef OBX_FCR_OPT_MAX_TX_B4_DISCNT
#define OBX_FCR_OPT_MAX_TX_B4_DISCNT 20
#endif

/*
 * Retransmission Timeout
 * Range: Minimum 2000 (2 secs) on BR/EDR when supporting PBF.
 */
#ifndef OBX_FCR_OPT_RETX_TOUT
#define OBX_FCR_OPT_RETX_TOUT 2000
#endif

/*
 * Monitor Timeout
 * Range: Minimum 12000 (12 secs) on BR/EDR when supporting PBF.
 */
#ifndef OBX_FCR_OPT_MONITOR_TOUT
#define OBX_FCR_OPT_MONITOR_TOUT 12000
#endif

/*
 * Maximum PDU payload size.
 * Suggestion: The maximum amount of data that will fit into a 3-DH5 packet.
 * Range: 2 octets
 */
#ifndef OBX_FCR_OPT_MAX_PDU_SIZE
#define OBX_FCR_OPT_MAX_PDU_SIZE L2CAP_MPS_OVER_BR_EDR
#endif

/******************************************************************************
/******************************************************************************
 *
 *
 * BNEP
 * BNEP
+0 −1
Original line number Original line Diff line number Diff line
@@ -198,7 +198,6 @@ extern void avct_bcb_dealloc(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);


extern const tAVCT_BCB_ACTION avct_bcb_action[];
extern const tAVCT_BCB_ACTION avct_bcb_action[];
extern const uint8_t avct_lcb_pkt_type_len[];
extern const uint8_t avct_lcb_pkt_type_len[];
extern const tL2CAP_FCR_OPTS avct_l2c_br_fcr_opts_def;


/* CCB function declarations */
/* CCB function declarations */
extern tAVCT_CCB* avct_ccb_alloc(tAVCT_CC* p_cc);
extern tAVCT_CCB* avct_ccb_alloc(tAVCT_CC* p_cc);
+2 −45
Original line number Original line Diff line number Diff line
@@ -37,38 +37,6 @@
#define AVCT_L2C_CFG_IND_DONE (1 << 0)
#define AVCT_L2C_CFG_IND_DONE (1 << 0)
#define AVCT_L2C_CFG_CFM_DONE (1 << 1)
#define AVCT_L2C_CFG_CFM_DONE (1 << 1)


/* AVCTP Browsing channel FCR Option:
 * Size of the transmission window when using enhanced retransmission mode. Not
 * used in basic and streaming modes. Range: 1 - 63
 */
#define AVCT_BR_FCR_OPT_TX_WINDOW_SIZE 10

/* AVCTP Browsing channel FCR Option:
 * Number of transmission attempts for a single I-Frame before taking
 * Down the connection. Used In ERTM mode only. Value is Ignored in basic and
 * Streaming modes.
 * Range: 0, 1-0xFF
 *     0 - infinite retransmissions
 *     1 - single transmission
 */
#define AVCT_BR_FCR_OPT_MAX_TX_B4_DISCNT 20

/* AVCTP Browsing channel FCR Option: Retransmission Timeout
 * The AVRCP specification set a value in the range of 300 - 2000 ms
 * Timeout (in msecs) to detect Lost I-Frames. Only used in Enhanced
 * retransmission mode.
 * Range: Minimum 2000 (2 secs) when supporting PBF.
 */
#define AVCT_BR_FCR_OPT_RETX_TOUT 2000

/* AVCTP Browsing channel FCR Option: Monitor Timeout
 * The AVRCP specification set a value in the range of 300 - 2000 ms
 * Timeout (in msecs) to detect Lost S-Frames. Only used in Enhanced
 * retransmission mode.
 * Range: Minimum 12000 (12 secs) when supporting PBF.
 */
#define AVCT_BR_FCR_OPT_MONITOR_TOUT 12000

/* callback function declarations */
/* callback function declarations */
void avct_l2c_br_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid,
void avct_l2c_br_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid,
                                   uint16_t psm, uint8_t id);
                                   uint16_t psm, uint8_t id);
@@ -90,17 +58,6 @@ const tL2CAP_APPL_INFO avct_l2c_br_appl = {avct_l2c_br_connect_ind_cback,
                                           NULL,
                                           NULL,
                                           /* tL2CA_TX_COMPLETE_CB */};
                                           /* tL2CA_TX_COMPLETE_CB */};


/* Browsing channel eL2CAP default options */
const tL2CAP_FCR_OPTS avct_l2c_br_fcr_opts_def = {
    L2CAP_FCR_ERTM_MODE,              /* Mandatory for Browsing channel */
    AVCT_BR_FCR_OPT_TX_WINDOW_SIZE,   /* Tx window size */
    AVCT_BR_FCR_OPT_MAX_TX_B4_DISCNT, /* Maximum transmissions before
                                         disconnecting */
    AVCT_BR_FCR_OPT_RETX_TOUT,        /* Retransmission timeout (2 secs) */
    AVCT_BR_FCR_OPT_MONITOR_TOUT,     /* Monitor timeout (12 secs) */
    L2CAP_DEFAULT_ERM_MPS             /* MPS segment size */
};

/*******************************************************************************
/*******************************************************************************
 *
 *
 * Function         avct_l2c_br_connect_ind_cback
 * Function         avct_l2c_br_connect_ind_cback
@@ -138,7 +95,7 @@ void avct_l2c_br_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid,
      cfg.mtu = kAvrcBrMtu;
      cfg.mtu = kAvrcBrMtu;


      cfg.fcr_present = true;
      cfg.fcr_present = true;
      cfg.fcr = avct_l2c_br_fcr_opts_def;
      cfg.fcr = kDefaultErtmOptions;
    }
    }
  }
  }
  /* else no control channel yet, reject */
  /* else no control channel yet, reject */
@@ -199,7 +156,7 @@ void avct_l2c_br_connect_cfm_cback(uint16_t lcid, uint16_t result) {
  cfg.mtu = kAvrcBrMtu;
  cfg.mtu = kAvrcBrMtu;


  cfg.fcr_present = true;
  cfg.fcr_present = true;
  cfg.fcr = avct_l2c_br_fcr_opts_def;
  cfg.fcr = kDefaultErtmOptions;


  L2CA_ConfigReq(lcid, &cfg);
  L2CA_ConfigReq(lcid, &cfg);
}
}
+10 −1
Original line number Original line Diff line number Diff line
@@ -100,7 +100,6 @@ typedef uint8_t tL2CAP_CHNL_DATA_RATE;
typedef struct {
typedef struct {
#define L2CAP_FCR_BASIC_MODE 0x00
#define L2CAP_FCR_BASIC_MODE 0x00
#define L2CAP_FCR_ERTM_MODE 0x03
#define L2CAP_FCR_ERTM_MODE 0x03
#define L2CAP_FCR_STREAM_MODE 0x04
#define L2CAP_FCR_LE_COC_MODE 0x05
#define L2CAP_FCR_LE_COC_MODE 0x05


  uint8_t mode;
  uint8_t mode;
@@ -112,6 +111,16 @@ typedef struct {
  uint16_t mps;
  uint16_t mps;
} tL2CAP_FCR_OPTS;
} tL2CAP_FCR_OPTS;


/* default options for ERTM mode */
constexpr tL2CAP_FCR_OPTS kDefaultErtmOptions = {
    L2CAP_FCR_ERTM_MODE,
    10,    /* Tx window size */
    20,    /* Maximum transmissions before disconnecting */
    2000,  /* Retransmission timeout (2 secs) */
    12000, /* Monitor timeout (12 secs) */
    1010   /* MPS segment size */
};

/* Define a structure to hold the configuration parameters. Since the
/* Define a structure to hold the configuration parameters. Since the
 * parameters are optional, for each parameter there is a boolean to
 * parameters are optional, for each parameter there is a boolean to
 * use to signify its presence or absence.
 * use to signify its presence or absence.