You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2023/10/26 11:45:37 UTC

[mynewt-nimble] 03/03: nimble/ll: Add option to discard excessive ISO SDUs

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

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

commit f92361828f9bc0bc12884173af820f80483d0df6
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Thu Oct 12 19:06:04 2023 +0200

    nimble/ll: Add option to discard excessive ISO SDUs
    
    See syscfg description for details.
---
 nimble/controller/src/ble_ll_isoal.c | 14 ++++++++++++++
 nimble/controller/syscfg.yml         | 12 ++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/nimble/controller/src/ble_ll_isoal.c b/nimble/controller/src/ble_ll_isoal.c
index 3ccf986d..fd9d205f 100644
--- a/nimble/controller/src/ble_ll_isoal.c
+++ b/nimble/controller/src/ble_ll_isoal.c
@@ -152,6 +152,20 @@ ble_ll_isoal_mux_event_done(struct ble_ll_isoal_mux *mux)
         mux->last_tx_packet_seq_num = blehdr->txiso.packet_seq_num;
     }
 
+#if MYNEWT_VAL(BLE_LL_ISO_HCI_DISCARD_THRESHOLD)
+    /* Drop queued SDUs if number of queued SDUs exceeds defined threshold.
+     * Threshold is defined as number of ISO events. If number of queued SDUs
+     * exceeds number of SDUs required for single event (i.e. including pt)
+     * and number of subsequent ISO events defined by threshold value, we'll
+     * drop any excessive SDUs and notify host as if they were sent.
+     */
+    uint32_t thr = MYNEWT_VAL(BLE_LL_ISO_HCI_DISCARD_THRESHOLD);
+    if (mux->sdu_q_len > mux->sdu_per_event + thr * mux->sdu_per_interval) {
+        num_sdu = mux->sdu_q_len - mux->sdu_per_event -
+                  thr * mux->sdu_per_interval;
+    }
+#endif
+
     while (pkthdr && num_sdu--) {
         OS_ENTER_CRITICAL(sr);
         STAILQ_REMOVE_HEAD(&mux->sdu_q, omp_next);
diff --git a/nimble/controller/syscfg.yml b/nimble/controller/syscfg.yml
index ae4b3c24..f1258917 100644
--- a/nimble/controller/syscfg.yml
+++ b/nimble/controller/syscfg.yml
@@ -502,6 +502,18 @@ syscfg.defs:
         experimental: 1
         restrictions:
             - BLE_LL_HCI_VS || BLE_LL_ISO_HCI_FEEDBACK_INTERVAL_MS == 0
+    BLE_LL_ISO_HCI_DISCARD_THRESHOLD:
+        description: >
+            Enables automatic discarding of excessive ISO SDUs to avoid exhaustion
+            of HCI ISO buffers in case host sends too many SDUs.
+            Threshold is defined as number of ISO events. If number of queued
+            SDUs exceeds number of SDUs required for single event (i.e. including
+            pre-transmissions) and number of subsequent ISO events defined by
+            threshold value, the controller will drop any excessive SDUs and
+            notify to host as if they were already sent.
+            Set to 0 to disable.
+        value: 0
+        experimental: 1
 
     BLE_LL_SYSINIT_STAGE:
         description: >