You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2017/02/13 19:31:38 UTC
[03/10] incubator-mynewt-core git commit: nimble/l2cap: Move
ble_l2cap_chan_mtu() to ble_att
nimble/l2cap: Move ble_l2cap_chan_mtu() to ble_att
MTU Exchange procedure belongs to ATT. Also concept of default MTU
belongs to ATT. This patch removes default_mtu from ble_l2cap_chan and
moves function choosing MTU for ATT channel to ble_att
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/552adce6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/552adce6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/552adce6
Branch: refs/heads/develop
Commit: 552adce6ed25a46eb40266342c719da478c89a6f
Parents: 1c66c79
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Fri Jan 20 13:06:13 2017 +0100
Committer: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Committed: Thu Feb 2 12:59:59 2017 +0100
----------------------------------------------------------------------
net/nimble/host/src/ble_att.c | 26 +++++++++++++++++++++---
net/nimble/host/src/ble_att_clt.c | 2 +-
net/nimble/host/src/ble_att_priv.h | 1 +
net/nimble/host/src/ble_att_svr.c | 2 +-
net/nimble/host/src/ble_l2cap.c | 21 +++----------------
net/nimble/host/src/ble_l2cap_priv.h | 4 +---
net/nimble/host/src/ble_l2cap_sig.c | 1 -
net/nimble/host/src/ble_sm.c | 1 -
net/nimble/host/test/src/ble_att_svr_test.c | 4 ++--
net/nimble/host/test/src/ble_hs_conn_test.c | 3 ---
net/nimble/host/test/src/ble_l2cap_test.c | 1 -
11 files changed, 32 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/552adce6/net/nimble/host/src/ble_att.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att.c b/net/nimble/host/src/ble_att.c
index 91bce94..ff1eebf 100644
--- a/net/nimble/host/src/ble_att.c
+++ b/net/nimble/host/src/ble_att.c
@@ -392,7 +392,7 @@ ble_att_truncate_to_mtu(const struct ble_l2cap_chan *att_chan,
int32_t extra_len;
uint16_t mtu;
- mtu = ble_l2cap_chan_mtu(att_chan);
+ mtu = ble_att_chan_mtu(att_chan);
extra_len = OS_MBUF_PKTLEN(txom) - mtu;
if (extra_len > 0) {
os_mbuf_adj(txom, -extra_len);
@@ -419,7 +419,7 @@ ble_att_mtu(uint16_t conn_handle)
ble_att_conn_chan_find(conn_handle, &conn, &chan);
if (chan != NULL) {
- mtu = ble_l2cap_chan_mtu(chan);
+ mtu = ble_att_chan_mtu(chan);
} else {
mtu = 0;
}
@@ -439,6 +439,27 @@ ble_att_set_peer_mtu(struct ble_l2cap_chan *chan, uint16_t peer_mtu)
chan->peer_mtu = peer_mtu;
}
+uint16_t
+ble_att_chan_mtu(const struct ble_l2cap_chan *chan)
+{
+ uint16_t mtu;
+
+ /* If either side has not exchanged MTU size, use the default. Otherwise,
+ * use the lesser of the two exchanged values.
+ */
+ if (!(ble_l2cap_is_mtu_req_sent(chan)) ||
+ chan->peer_mtu == 0) {
+
+ mtu = BLE_ATT_MTU_DFLT;
+ } else {
+ mtu = min(chan->my_mtu, chan->peer_mtu);
+ }
+
+ BLE_HS_DBG_ASSERT(mtu >= BLE_ATT_MTU_DFLT);
+
+ return mtu;
+}
+
static int
ble_att_rx(uint16_t conn_handle, struct os_mbuf **om)
{
@@ -541,7 +562,6 @@ ble_att_create_chan(void)
chan->scid = BLE_L2CAP_CID_ATT;
chan->my_mtu = ble_att_preferred_mtu_val;
- chan->default_mtu = BLE_ATT_MTU_DFLT;
chan->rx_fn = ble_att_rx;
return chan;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/552adce6/net/nimble/host/src/ble_att_clt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_clt.c b/net/nimble/host/src/ble_att_clt.c
index cdb4fa3..4a93171 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -185,7 +185,7 @@ ble_att_clt_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_conn_chan_find(conn_handle, NULL, &chan);
ble_att_set_peer_mtu(chan, cmd.bamc_mtu);
- mtu = ble_l2cap_chan_mtu(chan);
+ mtu = ble_att_chan_mtu(chan);
ble_hs_unlock();
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/552adce6/net/nimble/host/src/ble_att_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_priv.h b/net/nimble/host/src/ble_att_priv.h
index ed696df..22ed62e 100644
--- a/net/nimble/host/src/ble_att_priv.h
+++ b/net/nimble/host/src/ble_att_priv.h
@@ -166,6 +166,7 @@ void ble_att_inc_tx_stat(uint8_t att_op);
void ble_att_truncate_to_mtu(const struct ble_l2cap_chan *att_chan,
struct os_mbuf *txom);
void ble_att_set_peer_mtu(struct ble_l2cap_chan *chan, uint16_t peer_mtu);
+uint16_t ble_att_chan_mtu(const struct ble_l2cap_chan *chan);
int ble_att_init(void);
#define BLE_ATT_LOG_CMD(is_tx, cmd_name, conn_handle, log_cb, cmd) \
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/552adce6/net/nimble/host/src/ble_att_svr.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_svr.c b/net/nimble/host/src/ble_att_svr.c
index 8932f2f..1c2d4a2 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -766,7 +766,7 @@ done:
ble_att_conn_chan_find(conn_handle, &conn, &chan);
ble_att_set_peer_mtu(chan, cmd.bamc_mtu);
chan->flags |= BLE_L2CAP_CHAN_F_TXED_MTU;
- mtu = ble_l2cap_chan_mtu(chan);
+ mtu = ble_att_chan_mtu(chan);
ble_hs_unlock();
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/552adce6/net/nimble/host/src/ble_l2cap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap.c b/net/nimble/host/src/ble_l2cap.c
index 6b857f2..a61ada7 100644
--- a/net/nimble/host/src/ble_l2cap.c
+++ b/net/nimble/host/src/ble_l2cap.c
@@ -81,25 +81,10 @@ ble_l2cap_chan_free(struct ble_l2cap_chan *chan)
STATS_INC(ble_l2cap_stats, chan_delete);
}
-uint16_t
-ble_l2cap_chan_mtu(const struct ble_l2cap_chan *chan)
+bool
+ble_l2cap_is_mtu_req_sent(const struct ble_l2cap_chan *chan)
{
- uint16_t mtu;
-
- /* If either side has not exchanged MTU size, use the default. Otherwise,
- * use the lesser of the two exchanged values.
- */
- if (!(chan->flags & BLE_L2CAP_CHAN_F_TXED_MTU) ||
- chan->peer_mtu == 0) {
-
- mtu = chan->default_mtu;
- } else {
- mtu = min(chan->my_mtu, chan->peer_mtu);
- }
-
- BLE_HS_DBG_ASSERT(mtu >= chan->default_mtu);
-
- return mtu;
+ return (chan->flags & BLE_L2CAP_CHAN_F_TXED_MTU);
}
int
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/552adce6/net/nimble/host/src/ble_l2cap_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_priv.h b/net/nimble/host/src/ble_l2cap_priv.h
index ecdcf78..7733c20 100644
--- a/net/nimble/host/src/ble_l2cap_priv.h
+++ b/net/nimble/host/src/ble_l2cap_priv.h
@@ -68,7 +68,6 @@ struct ble_l2cap_chan {
uint16_t scid;
uint16_t my_mtu;
uint16_t peer_mtu; /* 0 if not exchanged. */
- uint16_t default_mtu;
ble_l2cap_chan_flags flags;
struct os_mbuf *rx_buf;
@@ -97,8 +96,7 @@ struct os_mbuf *ble_l2cap_prepend_hdr(struct os_mbuf *om, uint16_t cid,
struct ble_l2cap_chan *ble_l2cap_chan_alloc(void);
void ble_l2cap_chan_free(struct ble_l2cap_chan *chan);
-uint16_t ble_l2cap_chan_mtu(const struct ble_l2cap_chan *chan);
-
+bool ble_l2cap_is_mtu_req_sent(const struct ble_l2cap_chan *chan);
int ble_l2cap_rx(struct ble_hs_conn *conn,
struct hci_data_hdr *hci_hdr,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/552adce6/net/nimble/host/src/ble_l2cap_sig.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_sig.c b/net/nimble/host/src/ble_l2cap_sig.c
index e7c7704..09df2c3 100644
--- a/net/nimble/host/src/ble_l2cap_sig.c
+++ b/net/nimble/host/src/ble_l2cap_sig.c
@@ -525,7 +525,6 @@ ble_l2cap_sig_create_chan(void)
chan->scid = BLE_L2CAP_CID_SIG;
chan->my_mtu = BLE_L2CAP_SIG_MTU;
- chan->default_mtu = BLE_L2CAP_SIG_MTU;
chan->rx_fn = ble_l2cap_sig_rx;
return chan;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/552adce6/net/nimble/host/src/ble_sm.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm.c b/net/nimble/host/src/ble_sm.c
index 0227f1a..6f88830 100644
--- a/net/nimble/host/src/ble_sm.c
+++ b/net/nimble/host/src/ble_sm.c
@@ -2510,7 +2510,6 @@ ble_sm_create_chan(void)
chan->scid = BLE_L2CAP_CID_SM;
chan->my_mtu = BLE_SM_MTU;
- chan->default_mtu = BLE_SM_MTU;
chan->rx_fn = ble_sm_rx;
return chan;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/552adce6/net/nimble/host/test/src/ble_att_svr_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_att_svr_test.c b/net/nimble/host/test/src/ble_att_svr_test.c
index fa60abc..c2bc64a 100644
--- a/net/nimble/host/test/src/ble_att_svr_test.c
+++ b/net/nimble/host/test/src/ble_att_svr_test.c
@@ -398,7 +398,7 @@ ble_att_svr_test_misc_verify_tx_read_mult_rsp(
rc = ble_hs_misc_conn_chan_find(conn_handle, BLE_L2CAP_CID_ATT,
NULL, &chan);
TEST_ASSERT_FATAL(rc == 0);
- mtu = ble_l2cap_chan_mtu(chan);
+ mtu = ble_att_chan_mtu(chan);
ble_hs_unlock();
@@ -609,7 +609,7 @@ ble_att_svr_test_misc_mtu_exchange(uint16_t my_mtu, uint16_t peer_sent,
&conn, &chan);
TEST_ASSERT_FATAL(rc == 0);
TEST_ASSERT(chan->peer_mtu == peer_actual);
- TEST_ASSERT(ble_l2cap_chan_mtu(chan) == chan_mtu);
+ TEST_ASSERT(ble_att_chan_mtu(chan) == chan_mtu);
ble_hs_unlock();
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/552adce6/net/nimble/host/test/src/ble_hs_conn_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_hs_conn_test.c b/net/nimble/host/test/src/ble_hs_conn_test.c
index eb6da38..8ae4971 100644
--- a/net/nimble/host/test/src/ble_hs_conn_test.c
+++ b/net/nimble/host/test/src/ble_hs_conn_test.c
@@ -81,7 +81,6 @@ TEST_CASE(ble_hs_conn_test_direct_connect_success)
TEST_ASSERT_FATAL(chan != NULL);
TEST_ASSERT(chan->my_mtu == BLE_ATT_MTU_PREFERRED_DFLT);
TEST_ASSERT(chan->peer_mtu == 0);
- TEST_ASSERT(chan->default_mtu == BLE_ATT_MTU_DFLT);
ble_hs_unlock();
}
@@ -136,7 +135,6 @@ TEST_CASE(ble_hs_conn_test_direct_connectable_success)
TEST_ASSERT_FATAL(chan != NULL);
TEST_ASSERT(chan->my_mtu == BLE_ATT_MTU_PREFERRED_DFLT);
TEST_ASSERT(chan->peer_mtu == 0);
- TEST_ASSERT(chan->default_mtu == BLE_ATT_MTU_DFLT);
ble_hs_unlock();
}
@@ -198,7 +196,6 @@ TEST_CASE(ble_hs_conn_test_undirect_connectable_success)
TEST_ASSERT_FATAL(chan != NULL);
TEST_ASSERT(chan->my_mtu == BLE_ATT_MTU_PREFERRED_DFLT);
TEST_ASSERT(chan->peer_mtu == 0);
- TEST_ASSERT(chan->default_mtu == BLE_ATT_MTU_DFLT);
ble_hs_unlock();
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/552adce6/net/nimble/host/test/src/ble_l2cap_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_l2cap_test.c b/net/nimble/host/test/src/ble_l2cap_test.c
index 021ebb7..e8dbfa8 100644
--- a/net/nimble/host/test/src/ble_l2cap_test.c
+++ b/net/nimble/host/test/src/ble_l2cap_test.c
@@ -120,7 +120,6 @@ ble_l2cap_test_util_create_conn(uint16_t conn_handle, uint8_t *addr,
chan->scid = BLE_L2CAP_TEST_CID;
chan->my_mtu = 240;
- chan->default_mtu = 240;
chan->rx_fn = ble_l2cap_test_util_dummy_rx;
ble_hs_conn_chan_insert(conn, chan);