This ensures the MPS can fit in a single HCI fragment so each segment don't have to be reassembled at HCI level, in addition to that also remove the debugfs entry to configure the MPS.
Unified · Split
| @@ -456,7 +456,6 @@ struct l2cap_conn_param_update_rsp { · 455 unmodified lines | |||
| 456 | #define L2CAP_CONN_PARAM_REJECTED 0x0001 | 456 | #define L2CAP_CONN_PARAM_REJECTED 0x0001 |
| 457 | 457 | ||
| 458 | #define L2CAP_LE_MAX_CREDITS 10 | 458 | #define L2CAP_LE_MAX_CREDITS 10 |
| 459 | #define L2CAP_LE_DEFAULT_MPS 230 | ||
| 460 | 459 | ||
| 461 | struct l2cap_le_conn_req { | 460 | struct l2cap_le_conn_req { |
| 462 | __le16 psm; | 461 | __le16 psm; |
| @@ -52,7 +52,6 @@ static LIST_HEAD(chan_list); · 51 unmodified lines | |||
| 52 | static DEFINE_RWLOCK(chan_list_lock); | 52 | static DEFINE_RWLOCK(chan_list_lock); |
| 53 | 53 | ||
| 54 | static u16 le_max_credits = L2CAP_LE_MAX_CREDITS; | 54 | static u16 le_max_credits = L2CAP_LE_MAX_CREDITS; |
| 55 | static u16 le_default_mps = L2CAP_LE_DEFAULT_MPS; | ||
| 56 | 55 | ||
| 57 | static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, | 56 | static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, |
| 58 | u8 code, u8 ident, u16 dlen, void *data); | 57 | u8 code, u8 ident, u16 dlen, void *data); |
| @@ -520,7 +519,8 @@ static void l2cap_le_flowctl_init(struct l2cap_chan *chan) · 461 unmodified lines | |||
| 520 | chan->sdu_len = 0; | 519 | chan->sdu_len = 0; |
| 521 | chan->tx_credits = 0; | 520 | chan->tx_credits = 0; |
| 522 | chan->rx_credits = le_max_credits; | 521 | 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); | ||
| 524 | 524 | ||
| 525 | skb_queue_head_init(&chan->tx_q); | 525 | skb_queue_head_init(&chan->tx_q); |
| 526 | } | 526 | } |
| @@ -1282,6 +1282,8 @@ static void l2cap_le_connect(struct l2cap_chan *chan) · 755 unmodified lines | |||
| 1282 | if (test_and_set_bit(FLAG_LE_CONN_REQ_SENT, &chan->flags)) | 1282 | if (test_and_set_bit(FLAG_LE_CONN_REQ_SENT, &chan->flags)) |
| 1283 | return; | 1283 | return; |
| 1284 | 1284 | ||
| 1285 | l2cap_le_flowctl_init(chan); | ||
| 1286 | |||
| 1285 | req.psm = chan->psm; | 1287 | req.psm = chan->psm; |
| 1286 | req.scid = cpu_to_le16(chan->scid); | 1288 | req.scid = cpu_to_le16(chan->scid); |
| 1287 | req.mtu = cpu_to_le16(chan->imtu); | 1289 | req.mtu = cpu_to_le16(chan->imtu); |
| @@ -5493,8 +5495,6 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, · 4205 unmodified lines | |||
| 5493 | goto response_unlock; | 5495 | goto response_unlock; |
| 5494 | } | 5496 | } |
| 5495 | 5497 | ||
| 5496 | l2cap_le_flowctl_init(chan); | ||
| 5497 | |||
| 5498 | bacpy(&chan->src, &conn->hcon->src); | 5498 | bacpy(&chan->src, &conn->hcon->src); |
| 5499 | bacpy(&chan->dst, &conn->hcon->dst); | 5499 | bacpy(&chan->dst, &conn->hcon->dst); |
| 5500 | chan->src_type = bdaddr_src_type(conn->hcon); | 5500 | chan->src_type = bdaddr_src_type(conn->hcon); |
| @@ -5506,6 +5506,9 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, · 5 unmodified lines | |||
| 5506 | chan->tx_credits = __le16_to_cpu(req->credits); | 5506 | chan->tx_credits = __le16_to_cpu(req->credits); |
| 5507 | 5507 | ||
| 5508 | __l2cap_chan_add(conn, chan); | 5508 | __l2cap_chan_add(conn, chan); |
| 5509 | |||
| 5510 | l2cap_le_flowctl_init(chan); | ||
| 5511 | |||
| 5509 | dcid = chan->scid; | 5512 | dcid = chan->scid; |
| 5510 | credits = chan->rx_credits; | 5513 | credits = chan->rx_credits; |
| 5511 | 5514 | ||
| @@ -7102,7 +7105,6 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, · 1590 unmodified lines | |||
| 7102 | case L2CAP_MODE_BASIC: | 7105 | case L2CAP_MODE_BASIC: |
| 7103 | break; | 7106 | break; |
| 7104 | case L2CAP_MODE_LE_FLOWCTL: | 7107 | case L2CAP_MODE_LE_FLOWCTL: |
| 7105 | l2cap_le_flowctl_init(chan); | ||
| 7106 | break; | 7108 | break; |
| 7107 | case L2CAP_MODE_ERTM: | 7109 | case L2CAP_MODE_ERTM: |
| 7108 | case L2CAP_MODE_STREAMING: | 7110 | case L2CAP_MODE_STREAMING: |
| @@ -7647,8 +7649,6 @@ int __init l2cap_init(void) · 538 unmodified lines | |||
| 7647 | 7649 | ||
| 7648 | debugfs_create_u16("l2cap_le_max_credits", 0644, bt_debugfs, | 7650 | debugfs_create_u16("l2cap_le_max_credits", 0644, bt_debugfs, |
| 7649 | &le_max_credits); | 7651 | &le_max_credits); |
| 7650 | debugfs_create_u16("l2cap_le_default_mps", 0644, bt_debugfs, | ||
| 7651 | &le_default_mps); | ||
| 7652 | 7652 | ||
| 7653 | return 0; | 7653 | return 0; |
| 7654 | } | 7654 | } |