From 580f5b6dd8c56c4fe3e0b4df287c25506a8ec048 Mon Sep 17 00:00:00 2001 From: William San Filippo Date: Wed, 20 Jul 2016 04:19:57 -0700 Subject: MYNEWT-83: Use a fixed buffer for reception for controller stack The nimble stack was using mbufs for reception and now uses a static buffer. The reason behind the change is that we wanted to be able to receive a frame even though no mbufs were available. This would allow transmit packets to receive ACKs and thus free up transmit buffers waiting on connection queues. There were a number of code changes associated with the phy API. Implemented a more efficient copy routine to copy words from the static rx buffer into mbufs. Note that this is not yet done for transmit frames as we are not sure we could guarantee that the data pointer is aligned. --- net/nimble/controller/src/ble_ll_sched.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'net/nimble/controller/src/ble_ll_sched.c') diff --git a/net/nimble/controller/src/ble_ll_sched.c b/net/nimble/controller/src/ble_ll_sched.c index 5b792176..90cb510e 100644 --- a/net/nimble/controller/src/ble_ll_sched.c +++ b/net/nimble/controller/src/ble_ll_sched.c @@ -32,6 +32,10 @@ /* XXX: this is temporary. Not sure what I want to do here */ struct cpu_timer g_ble_ll_sched_timer; +#if (BLE_LL_SCHED_DEBUG == 1) +int32_t g_ble_ll_sched_max_late; +#endif + /* XXX: TODO: * 1) Add some accounting to the schedule code to see how late we are * (min/max?) @@ -645,6 +649,7 @@ ble_ll_sched_execute_item(struct ble_ll_sched_item *sch) } else { STATS_INC(ble_ll_stats, sched_state_conn_errs); ble_ll_conn_event_halt(); + return -1; } } @@ -663,12 +668,19 @@ ble_ll_sched_execute_item(struct ble_ll_sched_item *sch) void ble_ll_sched_run(void *arg) { + int32_t dt; struct ble_ll_sched_item *sch; /* Look through schedule queue */ while ((sch = TAILQ_FIRST(&g_ble_ll_sched_q)) != NULL) { /* Make sure we have passed the start time of the first event */ - if ((int32_t)(cputime_get32() - sch->start_time) >= 0) { + dt = (int32_t)(cputime_get32() - sch->start_time); + if (dt >= 0) { +#if (BLE_LL_SCHED_DEBUG == 1) + if (dt > g_ble_ll_sched_max_late) { + g_ble_ll_sched_max_late = dt; + } +#endif /* Remove schedule item and execute the callback */ TAILQ_REMOVE(&g_ble_ll_sched_q, sch, link); sch->enqueued = 0; -- cgit v1.2.3