This is an automated email from the ASF dual-hosted git repository. rymek pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 1fc7f44cf29fb815a66e6545cb4024f734c1ecf6 Author: Ćukasz Rymanowski <[email protected]> AuthorDate: Wed Feb 26 13:08:15 2020 +0100 nimble/l2cap: Minor change to avoid confusion on MPS/MTU meaning --- nimble/host/src/ble_l2cap_coc.c | 8 ++++---- nimble/host/src/ble_l2cap_priv.h | 16 ++++++++++++++-- nimble/host/src/ble_l2cap_sig.c | 8 ++++---- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/nimble/host/src/ble_l2cap_coc.c b/nimble/host/src/ble_l2cap_coc.c index c656ea1..798b0dc 100644 --- a/nimble/host/src/ble_l2cap_coc.c +++ b/nimble/host/src/ble_l2cap_coc.c @@ -290,7 +290,7 @@ ble_l2cap_coc_chan_alloc(struct ble_hs_conn *conn, uint16_t psm, uint16_t mtu, chan->cb = cb; chan->cb_arg = cb_arg; chan->scid = ble_l2cap_coc_get_cid(conn->l2cap_coc_cid_mask); - chan->my_mtu = MYNEWT_VAL(BLE_L2CAP_COC_MPS); + chan->my_coc_mps = MYNEWT_VAL(BLE_L2CAP_COC_MPS); chan->rx_fn = ble_l2cap_coc_rx_fn; chan->coc_rx.mtu = mtu; chan->coc_rx.sdu = sdu_rx; @@ -298,8 +298,8 @@ ble_l2cap_coc_chan_alloc(struct ble_hs_conn *conn, uint16_t psm, uint16_t mtu, /* Number of credits should allow to send full SDU with on given * L2CAP MTU */ - chan->coc_rx.credits = mtu / chan->my_mtu; - if (mtu % chan->my_mtu) { + chan->coc_rx.credits = mtu / chan->my_coc_mps; + if (mtu % chan->my_coc_mps) { chan->coc_rx.credits++; } @@ -412,7 +412,7 @@ ble_l2cap_coc_continue_tx(struct ble_l2cap_chan *chan) } /* Take into account peer MTU */ - len = min(left_to_send, chan->peer_mtu); + len = min(left_to_send, chan->peer_coc_mps); /* Prepare packet */ txom = ble_hs_mbuf_l2cap_pkt(); diff --git a/nimble/host/src/ble_l2cap_priv.h b/nimble/host/src/ble_l2cap_priv.h index 1585d66..937dbaf 100644 --- a/nimble/host/src/ble_l2cap_priv.h +++ b/nimble/host/src/ble_l2cap_priv.h @@ -65,8 +65,20 @@ struct ble_l2cap_chan { uint16_t conn_handle; uint16_t dcid; uint16_t scid; - uint16_t my_mtu; - uint16_t peer_mtu; /* 0 if not exchanged. */ + + /* Unions just to avoid confusion on MPS/MTU. + * In CoC context, L2CAP MTU is MPS + */ + union { + uint16_t my_mtu; + uint16_t my_coc_mps; + }; + + union { + uint16_t peer_mtu; + uint16_t peer_coc_mps; + }; + ble_l2cap_chan_flags flags; struct os_mbuf *rx_buf; diff --git a/nimble/host/src/ble_l2cap_sig.c b/nimble/host/src/ble_l2cap_sig.c index 11b8a88..b8beefe 100644 --- a/nimble/host/src/ble_l2cap_sig.c +++ b/nimble/host/src/ble_l2cap_sig.c @@ -692,7 +692,7 @@ ble_l2cap_sig_coc_req_rx(uint16_t conn_handle, struct ble_l2cap_sig_hdr *hdr, /* Fill up remote configuration. Note MPS is the L2CAP MTU*/ chan->dcid = scid; - chan->peer_mtu = le16toh(req->mps); + chan->peer_coc_mps = le16toh(req->mps); chan->coc_tx.credits = le16toh(req->credits); chan->coc_tx.mtu = le16toh(req->mtu); @@ -716,7 +716,7 @@ ble_l2cap_sig_coc_req_rx(uint16_t conn_handle, struct ble_l2cap_sig_hdr *hdr, rsp->dcid = htole16(chan->scid); rsp->credits = htole16(chan->coc_rx.credits); - rsp->mps = htole16(chan->my_mtu); + rsp->mps = htole16(chan->my_coc_mps); rsp->mtu = htole16(chan->coc_rx.mtu); rsp->result = htole16(BLE_L2CAP_COC_ERR_CONNECTION_SUCCESS); @@ -777,7 +777,7 @@ ble_l2cap_sig_coc_rsp_rx(uint16_t conn_handle, struct ble_l2cap_sig_hdr *hdr, /* Fill up remote configuration * Note MPS is the L2CAP MTU */ - chan->peer_mtu = le16toh(rsp->mps); + chan->peer_coc_mps = le16toh(rsp->mps); chan->dcid = le16toh(rsp->dcid); chan->coc_tx.mtu = le16toh(rsp->mtu); chan->coc_tx.credits = le16toh(rsp->credits); @@ -851,7 +851,7 @@ ble_l2cap_sig_coc_connect(uint16_t conn_handle, uint16_t psm, uint16_t mtu, req->psm = htole16(psm); req->scid = htole16(chan->scid); req->mtu = htole16(chan->coc_rx.mtu); - req->mps = htole16(chan->my_mtu); + req->mps = htole16(chan->my_coc_mps); req->credits = htole16(chan->coc_rx.credits); ble_hs_unlock();
