@@ -52,7 +52,6 @@ static LIST_HEAD(chan_list);
5252static DEFINE_RWLOCK (chan_list_lock );
5353
5454static u16 le_max_credits = L2CAP_LE_MAX_CREDITS ;
55- static u16 le_default_mps = L2CAP_LE_DEFAULT_MPS ;
5655
5756static struct sk_buff * l2cap_build_cmd (struct l2cap_conn * conn ,
5857 u8 code , u8 ident , u16 dlen , void * data );
@@ -520,7 +519,8 @@ static void l2cap_le_flowctl_init(struct l2cap_chan *chan)
520519 chan -> sdu_len = 0 ;
521520 chan -> tx_credits = 0 ;
522521 chan -> rx_credits = le_max_credits ;
523- chan -> mps = min_t (u16 , chan -> imtu , le_default_mps );
522+ /* Derive MPS from connection MTU to stop HCI fragmentation */
523+ chan -> mps = min_t (u16 , chan -> imtu , chan -> conn -> mtu - L2CAP_HDR_SIZE );
524524
525525 skb_queue_head_init (& chan -> tx_q );
526526}
@@ -1282,6 +1282,8 @@ static void l2cap_le_connect(struct l2cap_chan *chan)
12821282 if (test_and_set_bit (FLAG_LE_CONN_REQ_SENT , & chan -> flags ))
12831283 return ;
12841284
1285+ l2cap_le_flowctl_init (chan );
1286+
12851287 req .psm = chan -> psm ;
12861288 req .scid = cpu_to_le16 (chan -> scid );
12871289 req .mtu = cpu_to_le16 (chan -> imtu );
@@ -5493,8 +5495,6 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
54935495 goto response_unlock ;
54945496 }
54955497
5496- l2cap_le_flowctl_init (chan );
5497-
54985498 bacpy (& chan -> src , & conn -> hcon -> src );
54995499 bacpy (& chan -> dst , & conn -> hcon -> dst );
55005500 chan -> src_type = bdaddr_src_type (conn -> hcon );
@@ -5506,6 +5506,9 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
55065506 chan -> tx_credits = __le16_to_cpu (req -> credits );
55075507
55085508 __l2cap_chan_add (conn , chan );
5509+
5510+ l2cap_le_flowctl_init (chan );
5511+
55095512 dcid = chan -> scid ;
55105513 credits = chan -> rx_credits ;
55115514
@@ -7102,7 +7105,6 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
71027105 case L2CAP_MODE_BASIC :
71037106 break ;
71047107 case L2CAP_MODE_LE_FLOWCTL :
7105- l2cap_le_flowctl_init (chan );
71067108 break ;
71077109 case L2CAP_MODE_ERTM :
71087110 case L2CAP_MODE_STREAMING :
@@ -7647,8 +7649,6 @@ int __init l2cap_init(void)
76477649
76487650 debugfs_create_u16 ("l2cap_le_max_credits" , 0644 , bt_debugfs ,
76497651 & le_max_credits );
7650- debugfs_create_u16 ("l2cap_le_default_mps" , 0644 , bt_debugfs ,
7651- & le_default_mps );
76527652
76537653 return 0 ;
76547654}
0 commit comments