You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2017/04/03 22:36:43 UTC
incubator-mynewt-core git commit: MYNEWT-668: Improve throughput of
BLE connections
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop d416d5515 -> f6014227f
MYNEWT-668: Improve throughput of BLE connections
We will now send the number of completed packets event faster
than it was being sent before, assuming that more than 2 packets
were completed in a connection event. The old code would send
the event at the end of the connection event and this impacted
single connection throughput when trying to max out the
throughput.
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/f6014227
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f6014227
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f6014227
Branch: refs/heads/develop
Commit: f6014227f9173aec3c27e7c109f8a2289255eaca
Parents: d416d55
Author: William San Filippo <wi...@runtime.io>
Authored: Mon Apr 3 15:35:05 2017 -0700
Committer: William San Filippo <wi...@runtime.io>
Committed: Mon Apr 3 15:36:56 2017 -0700
----------------------------------------------------------------------
net/nimble/controller/include/controller/ble_ll.h | 3 +++
net/nimble/controller/src/ble_ll.c | 14 +++++++++-----
net/nimble/controller/src/ble_ll_conn.c | 8 +++++---
net/nimble/controller/src/ble_ll_conn_hci.c | 7 ++++++-
4 files changed, 23 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f6014227/net/nimble/controller/include/controller/ble_ll.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll.h b/net/nimble/controller/include/controller/ble_ll.h
index 2094290..f55bc8e 100644
--- a/net/nimble/controller/include/controller/ble_ll.h
+++ b/net/nimble/controller/include/controller/ble_ll.h
@@ -123,6 +123,9 @@ struct ble_ll_obj
/* Data buffer overflow event */
struct os_event ll_dbuf_overflow_ev;
+ /* Number of completed packets event */
+ struct os_event ll_comp_pkt_ev;
+
/* HW error callout */
struct os_callout ll_hw_err_timer;
};
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f6014227/net/nimble/controller/src/ble_ll.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll.c b/net/nimble/controller/src/ble_ll.c
index 3204ff2..72ec9cd 100644
--- a/net/nimble/controller/src/ble_ll.c
+++ b/net/nimble/controller/src/ble_ll.c
@@ -52,11 +52,6 @@
* 4) Should look into always disabled the wfr interrupt if we receive the
* start of a frame. Need to look at the various states to see if this is the
* right thing to do.
- * 5) I am not sure that if we are passed the output compare that we actually
- * get the interrupt. Test this.
- * 6) I am not sure that if we receive a packet while scanning that we actually
- * go back to scanning. I need to make sure we re-enable the receive.
- * Put an event in the log!
*/
/* Supported states */
@@ -987,6 +982,12 @@ ble_ll_event_dbuf_overflow(struct os_event *ev)
ble_ll_hci_ev_databuf_overflow();
}
+static void
+ble_ll_event_comp_pkts(struct os_event *ev)
+{
+ ble_ll_conn_num_comp_pkts_event_send(NULL);
+}
+
/**
* Link Layer task.
*
@@ -1268,7 +1269,10 @@ ble_ll_init(void)
/* Initialize transmit (from host) and receive packet (from phy) event */
lldata->ll_rx_pkt_ev.ev_cb = ble_ll_event_rx_pkt;
lldata->ll_tx_pkt_ev.ev_cb = ble_ll_event_tx_pkt;
+
+ /* Initialize data buffer overflow event and completed packets */
lldata->ll_dbuf_overflow_ev.ev_cb = ble_ll_event_dbuf_overflow;
+ lldata->ll_comp_pkt_ev.ev_cb = ble_ll_event_comp_pkts;
/* Initialize the HW error timer */
os_callout_init(&g_ble_ll_data.ll_hw_err_timer,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f6014227/net/nimble/controller/src/ble_ll_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn.c b/net/nimble/controller/src/ble_ll_conn.c
index 741ca0f..8d3173b 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -986,7 +986,7 @@ ble_ll_conn_tx_data_pdu(struct ble_ll_conn_sm *connsm)
}
ticks = os_cputime_usecs_to_ticks(ticks);
- if ((os_cputime_get32() + ticks) < next_event_time) {
+ if ((int32_t)((os_cputime_get32() + ticks) - next_event_time) < 0) {
md = 1;
}
}
@@ -3010,6 +3010,10 @@ ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr)
bletest_completed_pkt(connsm->conn_handle);
#endif
++connsm->completed_pkts;
+ if (connsm->completed_pkts > 2) {
+ os_eventq_put(&g_ble_ll_data.ll_evq,
+ &g_ble_ll_data.ll_comp_pkt_ev);
+ }
}
os_mbuf_free_chain(txpdu);
connsm->cur_tx_pdu = NULL;
@@ -3464,5 +3468,3 @@ ble_ll_conn_module_init(void)
/* Call reset to finish reset of initialization */
ble_ll_conn_module_reset();
}
-
-
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f6014227/net/nimble/controller/src/ble_ll_conn_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn_hci.c b/net/nimble/controller/src/ble_ll_conn_hci.c
index 9b25002..4239a66 100644
--- a/net/nimble/controller/src/ble_ll_conn_hci.c
+++ b/net/nimble/controller/src/ble_ll_conn_hci.c
@@ -253,11 +253,15 @@ ble_ll_conn_num_comp_pkts_event_send(struct ble_ll_conn_sm *connsm)
uint8_t *comp_pkt_ptr;
uint8_t handles;
+ if (connsm == NULL) {
+ goto skip_conn;
+ }
+
/*
* At some periodic rate, make sure we go through all active connections
* and send the number of completed packet events. We do this mainly
* because the spec says we must update the host even though no packets
- * have completed by there are data packets in the controller buffers
+ * have completed but there are data packets in the controller buffers
* (i.e. enqueued in a connection state machine).
*/
if ((uint32_t)(g_ble_ll_last_num_comp_pkt_evt - os_time_get()) <
@@ -283,6 +287,7 @@ ble_ll_conn_num_comp_pkts_event_send(struct ble_ll_conn_sm *connsm)
}
/* Iterate through all the active, created connections */
+skip_conn:
evbuf = NULL;
handles = 0;
handle_ptr = NULL;