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 2019/04/02 15:10:24 UTC

[mynewt-nimble] branch master updated: host: Always wake tx queues on rx of num-cmp-pkts

This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
     new 4a82ef4  host: Always wake tx queues on rx of num-cmp-pkts
4a82ef4 is described below

commit 4a82ef412ec213b93917f29fad7af75844ff04c2
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Fri Mar 29 11:03:25 2019 -0700

    host: Always wake tx queues on rx of num-cmp-pkts
    
    Prior to commit: The code assumed that a transmission could stall for
    only one reason: the controller cannot accommodate any more ACL data
    packets.  When the host received a num-complered-packets event, it would
    only try to unstall each connection if all the controller's data buffers
    were previously used.
    
    It turns out there is a second way that a host connection can stall:
    mbuf exhaustion. If the host is unable to fragment an outgoing L2CAP
    packet into ACL data packets due to a lack of mbufs, the transmission
    stalls.
    
    This commit causes the host to wake up its connections every time it
    receives a num-completed-packets event. It does this even if the
    controller still had capacity for more ACL data packets. If a host
    connection is stalled due to mbuf exhaustion, the controller will only
    send the next num-completed-packets event after it has freed the mbuf
    from the designated ACL fragment pool (ble_hs_hci_frag_mbuf_pool). In
    other words, we are guaranteed to receive a num-completed-packets event
    whenever a transmission has stalled, regardless of the cause.
---
 nimble/host/src/ble_hs_hci_evt.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/nimble/host/src/ble_hs_hci_evt.c b/nimble/host/src/ble_hs_hci_evt.c
index ec412f2..bd0fd00 100644
--- a/nimble/host/src/ble_hs_hci_evt.c
+++ b/nimble/host/src/ble_hs_hci_evt.c
@@ -226,7 +226,6 @@ ble_hs_hci_evt_num_completed_pkts(uint8_t event_code, uint8_t *data, int len)
     uint16_t num_pkts;
     uint16_t handle;
     uint8_t num_handles;
-    int tx_outstanding;
     int off;
     int i;
 
@@ -242,13 +241,6 @@ ble_hs_hci_evt_num_completed_pkts(uint8_t event_code, uint8_t *data, int len)
     }
     off++;
 
-    /* If we were previously blocked due to controller buffer exhaustion, and
-     * this event indicates that some buffers have been freed, then the host
-     * needs to resume transmitting.  `tx_outstanding` keeps track of whether
-     * this is the case.
-     */
-    tx_outstanding = 0;
-
     for (i = 0; i < num_handles; i++) {
         handle = get_le16(data + off);
         num_pkts = get_le16(data + off + 2);
@@ -264,19 +256,14 @@ ble_hs_hci_evt_num_completed_pkts(uint8_t event_code, uint8_t *data, int len)
                     conn->bhc_outstanding_pkts -= num_pkts;
                 }
 
-                if (ble_hs_hci_avail_pkts == 0) {
-                    tx_outstanding = 1;
-                }
-
                 ble_hs_hci_add_avail_pkts(num_pkts);
             }
             ble_hs_unlock();
         }
     }
 
-    if (tx_outstanding) {
-        ble_hs_wakeup_tx();
-    }
+    /* If any transmissions have stalled, wake them up now. */
+    ble_hs_wakeup_tx();
 
     return 0;
 }